Post#expunge!: fix remove_pool! to remove posts from deleted pools.

Don't silently ignore attempts to remove posts from deleted pools.
Remove the restriction on removing posts from deleted pools instead (ref: #1109).

Fixes failure to remove posts from deleted pools during expungement.
This commit is contained in:
evazion
2017-07-20 21:06:37 -05:00
parent 1b310dcc0b
commit fbee7f6912
3 changed files with 14 additions and 7 deletions

View File

@@ -86,15 +86,24 @@ class PostTest < ActiveSupport::TestCase
SqsService.any_instance.stubs(:send_message)
@pool = FactoryGirl.create(:pool)
@pool.add!(@post)
@post.reload
@deleted_pool = FactoryGirl.create(:pool)
@deleted_pool.add!(@post)
@deleted_pool.update_columns(is_deleted: true)
@post.expunge!
@pool.reload
@deleted_pool.reload
end
should "remove the post from all pools" do
@pool.reload
assert_equal("", @pool.post_ids)
end
should "remove the post from deleted pools" do
assert_equal("", @deleted_pool.post_ids)
end
should "destroy the record" do
assert_equal([], @post.errors.full_messages)
assert_equal(0, Post.where("id = ?", @post.id).count)