FIX: Remapping URLs didn't affect upload site settings

This commit is contained in:
Gerhard Schlager 2019-06-04 18:37:00 +02:00
parent f03a547a89
commit 98a3e61a2d
2 changed files with 22 additions and 9 deletions

View File

@ -293,15 +293,9 @@ module SiteSettingExtension
changes, deletions = diff_hash(new_hash, current) changes, deletions = diff_hash(new_hash, current)
changes.each do |name, val| changes.each { |name, val| current[name] = val }
current[name] = val deletions.each { |name, _| current[name] = defaults_view[name] }
clear_uploads_cache(name) uploads.clear
end
deletions.each do |name, _|
current[name] = defaults_view[name]
clear_uploads_cache(name)
end
clear_cache! clear_cache!
end end

View File

@ -143,6 +143,25 @@ describe SiteSettingExtension do
expect(settings.upload_type).to eq(upload2) expect(settings.upload_type).to eq(upload2)
end end
it "refreshes the client_settings_json cache" do
upload = Fabricate(:upload)
settings.setting(:upload_type, upload.id.to_s, type: :upload, client: true)
settings.setting(:string_type, 'haha', client: true)
settings.refresh!
expect(settings.client_settings_json).to eq(
%Q|{"default_locale":"#{SiteSetting.default_locale}","upload_type":"#{upload.url}","string_type":"haha"}|
)
upload.update!(url: "a_new_url")
settings.string_type = "changed"
settings.refresh!
expect(settings.client_settings_json).to eq(
%Q|{"default_locale":"#{SiteSetting.default_locale}","upload_type":"a_new_url","string_type":"changed"}|
)
end
end end
describe "multisite" do describe "multisite" do