tests: fix upload service tests.
Fix regression in a45bd52e9. Delay jobs so that that the dead upload pruner doesn't immediately prune new uploads.
This commit is contained in:
@@ -14,6 +14,14 @@ class UploadServiceTest < ActiveSupport::TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setup do
|
||||||
|
Delayed::Worker.delay_jobs = true
|
||||||
|
end
|
||||||
|
|
||||||
|
teardown do
|
||||||
|
Delayed::Worker.delay_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
context "::Utils" do
|
context "::Utils" do
|
||||||
subject { UploadService::Utils }
|
subject { UploadService::Utils }
|
||||||
|
|
||||||
@@ -781,14 +789,6 @@ class UploadServiceTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "a post with a pixiv html source" do
|
context "a post with a pixiv html source" do
|
||||||
setup do
|
|
||||||
Delayed::Worker.delay_jobs = true
|
|
||||||
end
|
|
||||||
|
|
||||||
teardown do
|
|
||||||
Delayed::Worker.delay_jobs = false
|
|
||||||
end
|
|
||||||
|
|
||||||
should "replace with the full size image" do
|
should "replace with the full size image" do
|
||||||
begin
|
begin
|
||||||
as_user do
|
as_user do
|
||||||
@@ -847,14 +847,6 @@ class UploadServiceTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "a post that is replaced to another file then replaced back to the original file" do
|
context "a post that is replaced to another file then replaced back to the original file" do
|
||||||
setup do
|
|
||||||
Delayed::Worker.delay_jobs = true
|
|
||||||
end
|
|
||||||
|
|
||||||
teardown do
|
|
||||||
Delayed::Worker.delay_jobs = false
|
|
||||||
end
|
|
||||||
|
|
||||||
should "not delete the original files" do
|
should "not delete the original files" do
|
||||||
begin
|
begin
|
||||||
FileUtils.expects(:rm_f).never
|
FileUtils.expects(:rm_f).never
|
||||||
@@ -885,18 +877,12 @@ class UploadServiceTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "two posts that have had their files swapped" do
|
context "two posts that have had their files swapped" do
|
||||||
setup do
|
setup do
|
||||||
Delayed::Worker.delay_jobs = true
|
|
||||||
|
|
||||||
as_user do
|
as_user do
|
||||||
@post1 = FactoryBot.create(:post)
|
@post1 = FactoryBot.create(:post)
|
||||||
@post2 = FactoryBot.create(:post)
|
@post2 = FactoryBot.create(:post)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
|
||||||
Delayed::Worker.delay_jobs = false
|
|
||||||
end
|
|
||||||
|
|
||||||
should "not delete the still active files" do
|
should "not delete the still active files" do
|
||||||
# swap the images between @post1 and @post2.
|
# swap the images between @post1 and @post2.
|
||||||
begin
|
begin
|
||||||
@@ -1016,11 +1002,6 @@ class UploadServiceTest < ActiveSupport::TestCase
|
|||||||
context "with a preprocessing predecessor" do
|
context "with a preprocessing predecessor" do
|
||||||
setup do
|
setup do
|
||||||
@predecessor = FactoryBot.create(:source_upload, status: "preprocessing", source: @source, image_height: 0, image_width: 0, file_ext: "jpg")
|
@predecessor = FactoryBot.create(:source_upload, status: "preprocessing", source: @source, image_height: 0, image_width: 0, file_ext: "jpg")
|
||||||
Delayed::Worker.delay_jobs = true
|
|
||||||
end
|
|
||||||
|
|
||||||
teardown do
|
|
||||||
Delayed::Worker.delay_jobs = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
should "schedule a job later" do
|
should "schedule a job later" do
|
||||||
|
|||||||
Reference in New Issue
Block a user