Skip to content

Commit

Permalink
FIX: Remapping URLs didn't affect upload site settings
Browse files Browse the repository at this point in the history
  • Loading branch information
gschlager committed Jun 4, 2019
1 parent f03a547 commit 98a3e61
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/site_setting_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,9 @@ def refresh!

changes, deletions = diff_hash(new_hash, current)

changes.each do |name, val|
current[name] = val
clear_uploads_cache(name)
end

deletions.each do |name, _|
current[name] = defaults_view[name]
clear_uploads_cache(name)
end
changes.each { |name, val| current[name] = val }
deletions.each { |name, _| current[name] = defaults_view[name] }
uploads.clear

clear_cache!
end
Expand Down
19 changes: 19 additions & 0 deletions spec/components/site_setting_extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,25 @@

expect(settings.upload_type).to eq(upload2)
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

describe "multisite" do
Expand Down

0 comments on commit 98a3e61

Please sign in to comment.