FIX: Clear uploads cache on SiteSetting.refresh!.

This fixes a bug where the return value of uploads site settings
may defer between processes even though we trigger a refresh via
MessageBus.
This commit is contained in:
Guo Xiang Tan
2018-11-16 11:02:51 +08:00
parent 9e86b425bc
commit 0ac5126a78
2 changed files with 36 additions and 4 deletions

View File

@ -133,6 +133,24 @@ describe SiteSettingExtension do
settings.foo = "baz"
expect(settings.foo).to eq("baz")
end
it "clears the cache for site setting uploads" do
settings.setting(:upload_type, "", type: :upload)
upload = Fabricate(:upload)
settings.upload_type = upload
expect(settings.upload_type).to eq(upload)
expect(settings.send(:uploads)[:upload_type]).to eq(upload)
upload2 = Fabricate(:upload)
settings.provider.save(:upload_type, upload2.id, SiteSetting.types[:upload])
expect do
settings.refresh!
end.to change { settings.send(:uploads)[:upload_type] }.from(upload).to(nil)
expect(settings.upload_type).to eq(upload2)
end
end
describe "multisite" do