mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
FEATURE: Allow theme settings to request refresh (#15037)
Similar to site settings, adds support for `refresh` option to theme settings. ```yaml super_feature_enabled: type: bool default: false refresh: true ```
This commit is contained in:
@ -902,4 +902,44 @@ HTML
|
||||
expect(new_digest).to eq(digest)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update_setting" do
|
||||
it "requests clients to refresh if `refresh: true`" do
|
||||
theme.set_field(target: :settings, name: "yaml", value: <<~YAML)
|
||||
super_feature_enabled:
|
||||
type: bool
|
||||
default: false
|
||||
refresh: true
|
||||
YAML
|
||||
|
||||
ThemeSetting.create!(theme: theme, data_type: ThemeSetting.types[:bool], name: "super_feature_enabled")
|
||||
theme.save!
|
||||
|
||||
messages = MessageBus.track_publish do
|
||||
theme.update_setting(:super_feature_enabled, true)
|
||||
theme.save!
|
||||
end.filter { |m| m.channel == "/global/asset-version" }
|
||||
|
||||
expect(messages.count).to eq(1)
|
||||
end
|
||||
|
||||
it "does not request clients to refresh if `refresh: false`" do
|
||||
theme.set_field(target: :settings, name: "yaml", value: <<~YAML)
|
||||
super_feature_enabled:
|
||||
type: bool
|
||||
default: false
|
||||
refresh: false
|
||||
YAML
|
||||
|
||||
ThemeSetting.create!(theme: theme, data_type: ThemeSetting.types[:bool], name: "super_feature_enabled")
|
||||
theme.save!
|
||||
|
||||
messages = MessageBus.track_publish do
|
||||
theme.update_setting(:super_feature_enabled, true)
|
||||
theme.save!
|
||||
end.filter { |m| m.channel == "/global/asset-version" }
|
||||
|
||||
expect(messages.count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user