favoritescontroller#destroy should work even if the post doesn't exist, remove from favorites on expunge (fixes #3222)

This commit is contained in:
r888888888
2017-07-19 13:22:24 -07:00
parent 5d013f9c88
commit d48ed95191
7 changed files with 50 additions and 21 deletions

View File

@@ -36,6 +36,7 @@ class PostTest < ActiveSupport::TestCase
@upload = FactoryGirl.create(:jpg_upload)
@upload.process!
@post = @upload.post
Favorite.add(post: @post, user: @user)
end
should "delete the files" do
@@ -52,6 +53,14 @@ class PostTest < ActiveSupport::TestCase
assert_equal(false, File.exists?(@post.file_path))
end
should "remove all favorites" do
TestAfterCommit.with_commits(true) do
@post.expunge!
end
assert_equal(0, Favorite.for_user(@user.id).where("post_id = ?", @post.id).count)
end
should "remove the post from iqdb" do
mock_iqdb_service!
Post.iqdb_sqs_service.expects(:send_message).with("remove\n#{@post.id}")

View File

@@ -40,7 +40,7 @@ class UserDeletionTest < ActiveSupport::TestCase
CurrentUser.ip_addr = "127.0.0.1"
@post = FactoryGirl.create(:post)
Favorite.add(@post, @user)
Favorite.add(post: @post, user: @user)
@user.update_attributes(:email => "ted@danbooru.com")