diff --git a/app/models/pool.rb b/app/models/pool.rb index ea9397a94..6b51bb5f2 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -129,7 +129,7 @@ class Pool < ApplicationRecord end def normalize_post_ids - self.post_ids = post_ids.uniq if is_collection? + self.post_ids = post_ids.uniq end def revert_to!(version) diff --git a/test/unit/pool_test.rb b/test/unit/pool_test.rb index f13335583..430490343 100644 --- a/test/unit/pool_test.rb +++ b/test/unit/pool_test.rb @@ -233,9 +233,12 @@ class PoolTest < ActiveSupport::TestCase assert_equal("A_B", @pool.name) end - should "normalize its post ids" do + should "not allow duplicate posts" do @pool.update(category: "collection", post_ids: [1, 2, 2, 3, 1]) assert_equal([1, 2, 3], @pool.post_ids) + + @pool.update(category: "series", post_ids: [1, 2, 2, 3, 1]) + assert_equal([1, 2, 3], @pool.post_ids) end context "when validating names" do