mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
add disk space usage failsafe
This commit is contained in:
@@ -275,6 +275,8 @@ describe CookedPostProcessor do
|
||||
let(:post) { build(:post) }
|
||||
let(:cpp) { CookedPostProcessor.new(post) }
|
||||
|
||||
before { cpp.stubs(:available_disk_space).returns(90) }
|
||||
|
||||
it "does not run when download_remote_images_to_local is disabled" do
|
||||
SiteSetting.stubs(:download_remote_images_to_local).returns(false)
|
||||
Jobs.expects(:cancel_scheduled_job).never
|
||||
@@ -291,6 +293,13 @@ describe CookedPostProcessor do
|
||||
cpp.pull_hotlinked_images
|
||||
end
|
||||
|
||||
it "disables download when disk space is low" do
|
||||
SiteSetting.expects(:download_remote_images_threshold).returns(20)
|
||||
cpp.expects(:available_disk_space).returns(10)
|
||||
Jobs.expects(:cancel_scheduled_job).never
|
||||
cpp.pull_hotlinked_images
|
||||
end
|
||||
|
||||
context "and the post has been updated by a user" do
|
||||
|
||||
before { post.id = 42 }
|
||||
@@ -310,4 +319,25 @@ describe CookedPostProcessor do
|
||||
|
||||
end
|
||||
|
||||
context ".disable_if_low_on_disk_space" do
|
||||
|
||||
let(:post) { build(:post) }
|
||||
let(:cpp) { CookedPostProcessor.new(post) }
|
||||
|
||||
before { cpp.expects(:available_disk_space).returns(50) }
|
||||
|
||||
it "does nothing when there's enough disk space" do
|
||||
SiteSetting.expects(:download_remote_images_threshold).returns(20)
|
||||
SiteSetting.expects(:download_remote_images_to_local).never
|
||||
cpp.disable_if_low_on_disk_space.should == false
|
||||
end
|
||||
|
||||
it "disables download_remote_images_threshold when there's not enough disk space" do
|
||||
SiteSetting.expects(:download_remote_images_threshold).returns(75)
|
||||
cpp.disable_if_low_on_disk_space.should == true
|
||||
SiteSetting.download_remote_images_to_local.should == false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user