pools: stop maintaining pool category pseudotags in pool strings (#4160)
Stop maintaining pool category pseudo tags (pool:series, pool:collection)
in pool strings. They're no longer used and the changes to the
`Post#pools` method in dc4d2e54b caused issues with this.
Also allow Members to change the category of large pools again. This was
only restricted because maintaining these pseudotags forced us to update
every post in the pool whenever a pool's category was changed.
This commit is contained in:
@@ -106,7 +106,7 @@ class PoolTest < ActiveSupport::TestCase
|
||||
assert_equal(@posts.map(&:id), @pool.post_ids)
|
||||
|
||||
@posts.each(&:reload)
|
||||
assert_equal(["pool:#{@pool.id} pool:series"] * @posts.size, @posts.map(&:pool_string))
|
||||
assert_equal(["pool:#{@pool.id}"] * @posts.size, @posts.map(&:pool_string))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -161,7 +161,7 @@ class PoolTest < ActiveSupport::TestCase
|
||||
|
||||
should "update any new posts that were added" do
|
||||
@p1.reload
|
||||
assert_equal("pool:#{@pool.id} pool:series", @p1.pool_string)
|
||||
assert_equal("pool:#{@pool.id}", @p1.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -194,7 +194,7 @@ class PoolTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "add the pool to the post" do
|
||||
assert_equal("pool:#{@pool.id} pool:series", @p1.pool_string)
|
||||
assert_equal("pool:#{@pool.id}", @p1.pool_string)
|
||||
end
|
||||
|
||||
should "increment the post count" do
|
||||
@@ -211,7 +211,7 @@ class PoolTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "not double add the pool to the post" do
|
||||
assert_equal("pool:#{@pool.id} pool:series", @p1.pool_string)
|
||||
assert_equal("pool:#{@pool.id}", @p1.pool_string)
|
||||
end
|
||||
|
||||
should "not double increment the post count" do
|
||||
@@ -279,7 +279,7 @@ class PoolTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "not affect the post" do
|
||||
assert_equal("pool:#{@pool.id} pool:series", @p1.pool_string)
|
||||
assert_equal("pool:#{@pool.id}", @p1.pool_string)
|
||||
end
|
||||
|
||||
should "not affect the post count" do
|
||||
@@ -288,37 +288,6 @@ class PoolTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "by changing the category" do
|
||||
setup do
|
||||
Danbooru.config.stubs(:pool_category_change_limit).returns(1)
|
||||
@pool.add!(@p1)
|
||||
@pool.add!(@p2)
|
||||
end
|
||||
|
||||
teardown do
|
||||
Danbooru.config.unstub(:pool_category_change_limit)
|
||||
end
|
||||
|
||||
should "not allow Members to change the category of large pools" do
|
||||
@member = FactoryBot.create(:member_user)
|
||||
as(@member) { @pool.update(category: "collection") }
|
||||
|
||||
assert_equal(["You cannot change the category of pools with greater than 1 posts"], @pool.errors[:base])
|
||||
end
|
||||
|
||||
should "allow Builders to change the category of large pools" do
|
||||
perform_enqueued_jobs do
|
||||
@builder = create(:builder_user)
|
||||
as(@builder) { @pool.update(category: "collection") }
|
||||
end
|
||||
|
||||
assert_equal(true, @pool.valid?)
|
||||
assert_equal("collection", @pool.category)
|
||||
assert_equal("pool:#{@pool.id} pool:collection", @p1.reload.pool_string)
|
||||
assert_equal("pool:#{@pool.id} pool:collection", @p2.reload.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
should "create new versions for each distinct user" do
|
||||
assert_equal(1, @pool.versions.size)
|
||||
user2 = travel_to(1.month.ago) {FactoryBot.create(:user)}
|
||||
@@ -406,7 +375,7 @@ class PoolTest < ActiveSupport::TestCase
|
||||
@p2.reload
|
||||
@p3.reload
|
||||
assert_equal("", @p1.pool_string)
|
||||
assert_equal("pool:#{@pool.id} pool:series", @p2.pool_string)
|
||||
assert_equal("pool:#{@pool.id}", @p2.pool_string)
|
||||
assert_equal("", @p3.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,7 +79,7 @@ class PostArchiveTest < ActiveSupport::TestCase
|
||||
|
||||
should "create a version" do
|
||||
assert_equal("tagme", @post.tag_string)
|
||||
assert_equal("pool:#{@pool.id} pool:series", @post.pool_string)
|
||||
assert_equal("pool:#{@pool.id}", @post.pool_string)
|
||||
|
||||
assert_equal(1, @post.versions.size)
|
||||
assert_equal("tagme", @post.versions.last.tags)
|
||||
|
||||
@@ -863,7 +863,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
@post.reload
|
||||
@pool.reload
|
||||
assert_equal([@post.id], @pool.post_ids)
|
||||
assert_equal("pool:#{@pool.id} pool:series", @post.pool_string)
|
||||
assert_equal("pool:#{@pool.id}", @post.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -894,7 +894,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
@post.reload
|
||||
@pool.reload
|
||||
assert_equal([@post.id], @pool.post_ids)
|
||||
assert_equal("pool:#{@pool.id} pool:series", @post.pool_string)
|
||||
assert_equal("pool:#{@pool.id}", @post.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -909,7 +909,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
@post.reload
|
||||
@pool.reload
|
||||
assert_equal([@post.id], @pool.post_ids)
|
||||
assert_equal("pool:#{@pool.id} pool:series", @post.pool_string)
|
||||
assert_equal("pool:#{@pool.id}", @post.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -920,7 +920,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
@post.reload
|
||||
assert_not_nil(@pool)
|
||||
assert_equal([@post.id], @pool.post_ids)
|
||||
assert_equal("pool:#{@pool.id} pool:series", @post.pool_string)
|
||||
assert_equal("pool:#{@pool.id}", @post.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1768,10 +1768,10 @@ class PostTest < ActiveSupport::TestCase
|
||||
pool = FactoryBot.create(:pool)
|
||||
post.add_pool!(pool)
|
||||
post.reload
|
||||
assert_equal("pool:#{pool.id} pool:series", post.pool_string)
|
||||
assert_equal("pool:#{pool.id}", post.pool_string)
|
||||
post.add_pool!(pool)
|
||||
post.reload
|
||||
assert_equal("pool:#{pool.id} pool:series", post.pool_string)
|
||||
assert_equal("pool:#{pool.id}", post.pool_string)
|
||||
post.remove_pool!(pool)
|
||||
post.reload
|
||||
assert_equal("", post.pool_string)
|
||||
|
||||
Reference in New Issue
Block a user