Fix #3822: Move favorites (while deleting) fails if user has also favorited destination

This commit is contained in:
evazion
2018-08-19 00:54:17 -05:00
parent eaef616a01
commit c504ad555d
2 changed files with 10 additions and 4 deletions

View File

@@ -68,7 +68,6 @@ class PostTest < ActiveSupport::TestCase
end
should "decrement the user's favorite count" do
@post.add_favorite!(@post.uploader)
assert_difference(["@post.uploader.reload.favorite_count"], -1) do
@post.expunge!
end
@@ -1720,13 +1719,13 @@ class PostTest < ActiveSupport::TestCase
assert_equal(0, @post.score)
end
should "update the fav strings ont he post" do
should "update the fav strings on the post" do
@post.add_favorite!(@user)
@post.reload
assert_equal("fav:#{@user.id}", @post.fav_string)
assert(Favorite.exists?(:user_id => @user.id, :post_id => @post.id))
@post.add_favorite!(@user)
assert_raises(Favorite::Error) { @post.add_favorite!(@user) }
@post.reload
assert_equal("fav:#{@user.id}", @post.fav_string)
assert(Favorite.exists?(:user_id => @user.id, :post_id => @post.id))