FEATURE: only export settings that changed via rake task

This commit is contained in:
Sam 2018-10-08 11:54:52 +11:00
parent 4000dddd32
commit 550e108a8c
2 changed files with 6 additions and 3 deletions

View File

@ -1,15 +1,16 @@
class SiteSettingsTask
def self.export_to_hash
def self.export_to_hash(include_defaults: false)
site_settings = SiteSetting.all_settings
h = {}
site_settings.each do |site_setting|
next if site_setting[:default] == site_setting[:value] if !include_defaults
h.store(site_setting[:setting].to_s, site_setting[:value])
end
h
end
def self.import(yml)
h = SiteSettingsTask.export_to_hash
h = SiteSettingsTask.export_to_hash(include_defaults: true)
counts = { updated: 0, not_found: 0, errors: 0 }
log = []

View File

@ -8,8 +8,10 @@ describe SiteSettingsTask do
describe 'export' do
it 'creates a hash of all site settings' do
SiteSetting.sso_url = "https://somewhere.over.com"
SiteSetting.enable_sso = true
h = SiteSettingsTask.export_to_hash
expect(h.count).to be > 0
expect(h.count).to eq(2)
end
end