FIX: Prevent uploads used in site settings from being deleted.

This commit is contained in:
Guo Xiang Tan 2018-11-13 09:15:16 +08:00
parent 27ce8cf851
commit 7b44339529
2 changed files with 23 additions and 0 deletions

View File

@ -22,7 +22,12 @@ module Jobs
ignore_urls = [
SiteSetting.logo_url,
SiteSetting.logo_small_url,
SiteSetting.digest_logo_url,
SiteSetting.mobile_logo_url,
SiteSetting.large_icon_url,
SiteSetting.favicon_url,
SiteSetting.default_opengraph_image_url,
SiteSetting.twitter_summary_large_image_url,
SiteSetting.apple_touch_icon_url,
*SiteSetting.selectable_avatars.split("\n"),
].flatten.map do |url|

View File

@ -47,6 +47,11 @@ describe Jobs::CleanUpUploads do
it "does not clean up uploads in site settings" do
logo_upload = fabricate_upload
logo_small_upload = fabricate_upload
digest_logo_upload = fabricate_upload
mobile_logo_upload = fabricate_upload
large_icon_upload = fabricate_upload
default_opengraph_image_upload = fabricate_upload
twitter_summary_large_image_upload = fabricate_upload
favicon_upload = fabricate_upload
apple_touch_icon_upload = fabricate_upload
avatar1_upload = fabricate_upload
@ -54,6 +59,14 @@ describe Jobs::CleanUpUploads do
SiteSetting.logo_url = logo_upload.url
SiteSetting.logo_small_url = logo_small_upload.url
SiteSetting.digest_logo_url = digest_logo_upload.url
SiteSetting.mobile_logo_url = mobile_logo_upload.url
SiteSetting.large_icon_url = large_icon_upload.url
SiteSetting.default_opengraph_image_url = default_opengraph_image_upload.url
SiteSetting.twitter_summary_large_image_url =
twitter_summary_large_image_upload.url
SiteSetting.favicon_url = favicon_upload.url
SiteSetting.apple_touch_icon_url = apple_touch_icon_upload.url
SiteSetting.selectable_avatars = [avatar1_upload.url, avatar2_upload.url].join("\n")
@ -63,6 +76,11 @@ describe Jobs::CleanUpUploads do
expect(Upload.exists?(id: @upload.id)).to eq(false)
expect(Upload.exists?(id: logo_upload.id)).to eq(true)
expect(Upload.exists?(id: logo_small_upload.id)).to eq(true)
expect(Upload.exists?(id: digest_logo_upload.id)).to eq(true)
expect(Upload.exists?(id: mobile_logo_upload.id)).to eq(true)
expect(Upload.exists?(id: large_icon_upload.id)).to eq(true)
expect(Upload.exists?(id: default_opengraph_image_upload.id)).to eq(true)
expect(Upload.exists?(id: twitter_summary_large_image_upload.id)).to eq(true)
expect(Upload.exists?(id: favicon_upload.id)).to eq(true)
expect(Upload.exists?(id: apple_touch_icon_upload.id)).to eq(true)
expect(Upload.exists?(id: avatar1_upload.id)).to eq(true)