Fix #3981: Inconsistency between posts and pools.
This commit is contained in:
@@ -241,8 +241,9 @@ class Pool < ApplicationRecord
|
||||
end
|
||||
|
||||
def synchronize
|
||||
added = post_ids - post_ids_was
|
||||
removed = post_ids_was - post_ids
|
||||
post_ids_before = post_ids_before_last_save || post_ids_was
|
||||
added = post_ids - post_ids_before
|
||||
removed = post_ids_before - post_ids
|
||||
|
||||
added.each do |post_id|
|
||||
post = Post.find(post_id)
|
||||
|
||||
@@ -61,6 +61,13 @@ class PoolTest < ActiveSupport::TestCase
|
||||
should "initialize the post count" do
|
||||
assert_equal(@posts.size, @pool.post_count)
|
||||
end
|
||||
|
||||
should "synchronize the posts with the pool" do
|
||||
assert_equal(@posts.map(&:id), @pool.post_ids)
|
||||
|
||||
@posts.each(&:reload)
|
||||
assert_equal(["pool:#{@pool.id} pool:series"] * @posts.size, @posts.map(&:pool_string))
|
||||
end
|
||||
end
|
||||
|
||||
context "Reverting a pool" do
|
||||
|
||||
Reference in New Issue
Block a user