Merge pull request #3158 from evazion/fix-expunge-post
Fix #3156: Expunging posts is broken
This commit is contained in:
@@ -16,6 +16,7 @@ module IqdbTestHelper
|
||||
|
||||
service = mock_sqs_service.new
|
||||
Post.stubs(:iqdb_sqs_service).returns(service)
|
||||
Post.stubs(:iqdb_enabled?).returns(true)
|
||||
|
||||
Danbooru.config.stubs(:iqdbs_auth_key).returns("hunter2")
|
||||
Danbooru.config.stubs(:iqdbs_server).returns("http://localhost:3004")
|
||||
|
||||
@@ -48,6 +48,7 @@ class ActionController::TestCase
|
||||
end
|
||||
|
||||
Delayed::Worker.delay_jobs = false
|
||||
TestAfterCommit.enabled = false
|
||||
|
||||
require "helpers/reportbooru_helper"
|
||||
class ActiveSupport::TestCase
|
||||
|
||||
@@ -33,7 +33,32 @@ class PostTest < ActiveSupport::TestCase
|
||||
context "Deletion:" do
|
||||
context "Expunging a post" do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post)
|
||||
@upload = FactoryGirl.create(:jpg_upload)
|
||||
@upload.process!
|
||||
@post = @upload.post
|
||||
end
|
||||
|
||||
should "delete the files" do
|
||||
assert_equal(true, File.exists?(@post.preview_file_path))
|
||||
assert_equal(true, File.exists?(@post.large_file_path))
|
||||
assert_equal(true, File.exists?(@post.file_path))
|
||||
|
||||
TestAfterCommit.with_commits(true) do
|
||||
@post.expunge!
|
||||
end
|
||||
|
||||
assert_equal(false, File.exists?(@post.preview_file_path))
|
||||
assert_equal(false, File.exists?(@post.large_file_path))
|
||||
assert_equal(false, File.exists?(@post.file_path))
|
||||
end
|
||||
|
||||
should "remove the post from iqdb" do
|
||||
mock_iqdb_service!
|
||||
Post.iqdb_sqs_service.expects(:send_message).with("remove\n#{@post.id}")
|
||||
|
||||
TestAfterCommit.with_commits(true) do
|
||||
@post.expunge!
|
||||
end
|
||||
end
|
||||
|
||||
context "that is status locked" do
|
||||
|
||||
Reference in New Issue
Block a user