mirror of
https://github.com/discourse/discourse.git
synced 2025-03-06 12:15:29 +08:00
FEATURE: Allow import of hidden site settings (#7601)
* Allow optional import of hidden site settings * Always import hidden settings
This commit is contained in:
parent
315a38e0e3
commit
0d9fdbf8fe
@ -1,8 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SiteSettingsTask
|
||||
def self.export_to_hash(include_defaults: false)
|
||||
site_settings = SiteSetting.all_settings
|
||||
def self.export_to_hash(include_defaults: false, include_hidden: false)
|
||||
site_settings = SiteSetting.all_settings(include_hidden)
|
||||
h = {}
|
||||
site_settings.each do |site_setting|
|
||||
next if site_setting[:default] == site_setting[:value] if !include_defaults
|
||||
@ -12,7 +12,7 @@ class SiteSettingsTask
|
||||
end
|
||||
|
||||
def self.import(yml)
|
||||
h = SiteSettingsTask.export_to_hash(include_defaults: true)
|
||||
h = SiteSettingsTask.export_to_hash(include_defaults: true, include_hidden: true)
|
||||
counts = { updated: 0, not_found: 0, errors: 0 }
|
||||
log = []
|
||||
|
||||
|
@ -31,6 +31,14 @@ describe SiteSettingsTask do
|
||||
expect(SiteSetting.title).to eq "Test"
|
||||
end
|
||||
|
||||
it "updates hidden settings" do
|
||||
yml = "logo_url: /logo.png"
|
||||
log, counts = SiteSettingsTask.import(yml)
|
||||
expect(log[0]).to eq "Changed logo_url FROM: /images/d-logo-sketch.png TO: /logo.png"
|
||||
expect(counts[:updated]).to eq 1
|
||||
expect(SiteSetting.logo_url).to eq "/logo.png"
|
||||
end
|
||||
|
||||
it "won't update a setting that doesn't exist" do
|
||||
yml = "fake_setting: foo"
|
||||
log, counts = SiteSettingsTask.import(yml)
|
||||
|
Loading…
x
Reference in New Issue
Block a user