FIX: Remapping URLs didn't affect upload site settings

FIX: Remapping URLs didn’t affect upload site settings

diff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rb
index 59dc8b7..8b9e49f 100644
--- a/lib/site_setting_extension.rb
+++ b/lib/site_setting_extension.rb
@@ -293,15 +293,9 @@ module SiteSettingExtension
 
       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
diff --git a/spec/components/site_setting_extension_spec.rb b/spec/components/site_setting_extension_spec.rb
index 9b225f0..809a1b7 100644
--- a/spec/components/site_setting_extension_spec.rb
+++ b/spec/components/site_setting_extension_spec.rb
@@ -143,6 +143,25 @@ describe SiteSettingExtension do
 
       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

GitHub sha: 98a3e61a

1 Like