favoritescontroller#destroy should work even if the post doesn't exist, remove from favorites on expunge (fixes #3222)
This commit is contained in:
@@ -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}")
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user