Skip to content

A platform for community discussion. Free, open, simple.

DEV: Fix upcoming change specs (#37399)

Martin Brennan89f9423e4a9b
diff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rb
index 5873a7f1485..7c993fc354b 100644
--- a/lib/site_setting_extension.rb
+++ b/lib/site_setting_extension.rb
@@ -364,13 +364,11 @@ module SiteSettingExtension
if type_supervisor.dependencies[setting_name].present? &&
type_supervisor.dependencies.behaviors[setting_name] == :hidden
- # Hidden if any of the dependent settings are not true
+ # Hidden if any of the dependent settings are not true. Use the getter so upcoming
+ # change settings use their resolved value (promotion status, admin override, etc.).
is_hidden =
!type_supervisor.dependencies[setting_name].all? do |dependency|
- # TODO (martin) Fix this when https://github.com/discourse/discourse/pull/37283 is merged
- # to take into account the dynamic upcoming change settings based on promotion status
- # using UpcomingChange.resolved_value
- current[dependency.to_sym]
+ public_send(dependency)
end
end
diff --git a/spec/lib/site_setting_extension_spec.rb b/spec/lib/site_setting_extension_spec.rb
index 024fedbdc77..4c0aec6eb0b 100644
--- a/spec/lib/site_setting_extension_spec.rb
+++ b/spec/lib/site_setting_extension_spec.rb
@@ -725,6 +725,9 @@ RSpec.describe SiteSettingExtension do
},
)
settings.refresh!
+ allow(UpcomingChanges).to receive(:resolved_value).with(:enable_cool_thing).and_return(
+ true,
+ )
end
it "is present in all_settings" do
@@ -735,10 +738,22 @@ RSpec.describe SiteSettingExtension do
end
context "when the upcoming change is automatically enabled because of the promotion status" do
- # TODO (martin) Fix this when https://github.com/discourse/discourse/pull/37283 is merged
- # to take into account the dynamic upcoming change settings based on promotion status
- # using UpcomingChange.resolved_value
- xit "is present in all_settings" do
+ before do
+ settings.setting(
+ :enable_cool_thing,
+ true,
+ upcoming_change: {
+ status: :alpha,
+ impact: "feature,staff",
+ },
+ )
+ settings.refresh!
+ allow(UpcomingChanges).to receive(:resolved_value).with(:enable_cool_thing).and_return(
+ true,
+ )
+ end
+
+ it "is present in all_settings" do
expect(
settings.all_settings.find { |s| s[:setting] == :cool_thing_image },
).not_to be_blank