This commit is contained in:
r888888888
2013-05-21 18:02:35 -07:00
parent cb2e1e9f57
commit 54e5869dfc
2 changed files with 15 additions and 0 deletions

View File

@@ -617,6 +617,12 @@ class Post < ActiveRecord::Base
update_column(:pool_string, pool_string) unless new_record?
pool.remove!(self)
end
def remove_from_all_pools
pools.find_each do |pool|
pool.remove!(self)
end
end
end
module VoteMethods
@@ -823,6 +829,7 @@ class Post < ActiveRecord::Base
update_children_on_destroy
update_parent_on_destroy
decrement_tag_post_counts
remove_from_all_pools
destroy
end

View File

@@ -31,6 +31,14 @@ class PostTest < ActiveSupport::TestCase
end
end
should "remove the post from all pools" do
pool = FactoryGirl.create(:pool)
pool.add!(@post)
@post.expunge!
pool.reload
assert_equal("", pool.post_ids)
end
should "destroy the record" do
@post.expunge!
assert_equal([], @post.errors.full_messages)