mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 18:41:09 +08:00
FEATURE: new site setting download_remote_images_max_days_old
This commit is contained in:
@ -413,7 +413,7 @@ describe CookedPostProcessor do
|
||||
|
||||
context ".pull_hotlinked_images" do
|
||||
|
||||
let(:post) { build(:post) }
|
||||
let(:post) { build(:post, created_at: 20.days.ago) }
|
||||
let(:cpp) { CookedPostProcessor.new(post) }
|
||||
|
||||
before { cpp.stubs(:available_disk_space).returns(90) }
|
||||
@ -467,7 +467,7 @@ describe CookedPostProcessor do
|
||||
|
||||
context ".disable_if_low_on_disk_space" do
|
||||
|
||||
let(:post) { build(:post) }
|
||||
let(:post) { build(:post, created_at: 20.days.ago) }
|
||||
let(:cpp) { CookedPostProcessor.new(post) }
|
||||
|
||||
before { cpp.expects(:available_disk_space).returns(50) }
|
||||
@ -493,6 +493,34 @@ describe CookedPostProcessor do
|
||||
|
||||
end
|
||||
|
||||
context ".download_remote_images_max_days_old" do
|
||||
|
||||
let(:post) { build(:post, created_at: 20.days.ago) }
|
||||
let(:cpp) { CookedPostProcessor.new(post) }
|
||||
|
||||
before do
|
||||
SiteSetting.download_remote_images_to_local = true
|
||||
cpp.expects(:disable_if_low_on_disk_space).returns(false)
|
||||
end
|
||||
|
||||
it "does not run when download_remote_images_max_days_old is not satisfied" do
|
||||
SiteSetting.download_remote_images_max_days_old = 15
|
||||
Jobs.expects(:cancel_scheduled_job).never
|
||||
cpp.pull_hotlinked_images
|
||||
end
|
||||
|
||||
it "runs when download_remote_images_max_days_old is satisfied" do
|
||||
SiteSetting.download_remote_images_max_days_old = 30
|
||||
|
||||
Jobs.expects(:cancel_scheduled_job).with(:pull_hotlinked_images, post_id: post.id).once
|
||||
|
||||
delay = SiteSetting.editing_grace_period + 1
|
||||
Jobs.expects(:enqueue_in).with(delay.seconds, :pull_hotlinked_images, post_id: post.id, bypass_bump: false).once
|
||||
|
||||
cpp.pull_hotlinked_images
|
||||
end
|
||||
end
|
||||
|
||||
context ".is_a_hyperlink?" do
|
||||
|
||||
let(:post) { build(:post) }
|
||||
|
Reference in New Issue
Block a user