discourse/spec/lib/site_settings/deprecated_settings_spec.rb
Jarek Radosz 5ce33991f4
DEV: Fix flaky deprecated setting specs (#30550)
…and remove obsolete (and already-disabled) TL-migration related specs
2025-01-04 12:55:22 +01:00

54 lines
1.6 KiB
Ruby

# frozen_string_literal: true
RSpec.describe SiteSettings::DeprecatedSettings do
describe "when not overriding deprecated settings" do
it "does not act as a proxy to the new methods" do
stub_deprecated_settings!(override: false) do
SiteSetting.old_one = true
expect(SiteSetting.new_one).to eq(false)
expect(SiteSetting.new_one?).to eq(false)
end
end
it "logs warnings when deprecated settings are called" do
stub_deprecated_settings!(override: false) do
logger =
track_log_messages do
expect(SiteSetting.old_one).to eq(false)
expect(SiteSetting.old_one?).to eq(false)
end
expect(logger.warnings.count).to eq(3)
logger = track_log_messages { SiteSetting.old_one(warn: false) }
expect(logger.warnings.count).to eq(0)
end
end
end
describe "when overriding deprecated settings" do
it "acts as a proxy to the new methods" do
stub_deprecated_settings!(override: true) do
SiteSetting.old_one = true
expect(SiteSetting.new_one).to eq(true)
expect(SiteSetting.new_one?).to eq(true)
end
end
it "logs warnings when deprecated settings are called" do
stub_deprecated_settings!(override: true) do
logger =
track_log_messages do
expect(SiteSetting.old_one).to eq(false)
expect(SiteSetting.old_one?).to eq(false)
end
expect(logger.warnings.count).to eq(2)
logger = track_log_messages { SiteSetting.old_one(warn: false) }
expect(logger.warnings.count).to eq(0)
end
end
end
end