FEATURE: Allow import of hidden site settings (#7601)

FEATURE: Allow import of hidden site settings (#7601)

  • Allow optional import of hidden site settings

  • Always import hidden settings

diff --git a/app/services/site_settings_task.rb b/app/services/site_settings_task.rb
index 8cbb4cf..4cddf6d 100644
--- a/app/services/site_settings_task.rb
+++ b/app/services/site_settings_task.rb
@@ -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 = []
 
diff --git a/spec/services/site_settings_spec.rb b/spec/services/site_settings_spec.rb
index c76c017..c622ad1 100644
--- a/spec/services/site_settings_spec.rb
+++ b/spec/services/site_settings_spec.rb
@@ -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)

GitHub sha: 0d9fdbf8

1 Like