fixes #1636
This commit is contained in:
@@ -617,6 +617,12 @@ class Post < ActiveRecord::Base
|
|||||||
update_column(:pool_string, pool_string) unless new_record?
|
update_column(:pool_string, pool_string) unless new_record?
|
||||||
pool.remove!(self)
|
pool.remove!(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_from_all_pools
|
||||||
|
pools.find_each do |pool|
|
||||||
|
pool.remove!(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module VoteMethods
|
module VoteMethods
|
||||||
@@ -823,6 +829,7 @@ class Post < ActiveRecord::Base
|
|||||||
update_children_on_destroy
|
update_children_on_destroy
|
||||||
update_parent_on_destroy
|
update_parent_on_destroy
|
||||||
decrement_tag_post_counts
|
decrement_tag_post_counts
|
||||||
|
remove_from_all_pools
|
||||||
destroy
|
destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,14 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
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
|
should "destroy the record" do
|
||||||
@post.expunge!
|
@post.expunge!
|
||||||
assert_equal([], @post.errors.full_messages)
|
assert_equal([], @post.errors.full_messages)
|
||||||
|
|||||||
Reference in New Issue
Block a user