A platform for community discussion. Free, open, simple.
FEATURE: Allow import of hidden site settings (#7601)
Ralph Rooding0d9fdbf8fefb
diff --git a/app/services/site_settings_task.rb b/app/services/site_settings_task.rbindex 8cbb4cfc57b..4cddf6d4dc9 100644--- a/app/services/site_settings_task.rb+++ b/app/services/site_settings_task.rb@@ -1,8 +1,8 @@# frozen_string_literal: trueclass 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 SiteSettingsTaskenddef 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 = []diff --git a/spec/services/site_settings_spec.rb b/spec/services/site_settings_spec.rbindex c76c017f363..c622ad1a395 100644--- a/spec/services/site_settings_spec.rb+++ b/spec/services/site_settings_spec.rb@@ -31,6 +31,14 @@ describe SiteSettingsTask doexpect(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" doyml = "fake_setting: foo"log, counts = SiteSettingsTask.import(yml)