posts: stop using pool_string attribute.
Stop using the pool_string attribute on posts: * Stop updating it when adding or removing posts from pools. * Stop returning pool_string in the /posts.json API. * Stop including the `data-pools` attribute on thumbnails. The pool_string attribute was used in the past to facilitate pool:X searches. Posts had a hidden pool_string attribute that contained a list of every pool the post belonged to. These pools were treated like fake hidden tags on the post and a search for `pool:X` was treated like a tag search. The pool_string has no longer been used for this purpose for a long time now, and was only maintained for API compatibility purposes. Getting rid of it eliminates a bunch of legacy cruft relating to adding and removing posts from pools. If you need to see which pools a post belongs to, do this: * https://danbooru.donmai.us/pools.json?search[post_ids_include_any]=318550 The `data-pools` attribute on thumbnails was used by some people to add custom borders to pooled posts with custom CSS. This will no longer work. This was already broken because it included things like collection pools and deleted pools, which you probably didn't want. Use a userscript to add this attribute back to thumbnails if you need it.
This commit is contained in:
@@ -68,13 +68,6 @@ 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}"] * @posts.size, @posts.map(&:pool_string))
|
||||
end
|
||||
end
|
||||
|
||||
context "Reverting a pool" do
|
||||
@@ -94,19 +87,15 @@ class PoolTest < ActiveSupport::TestCase
|
||||
assert_equal([], @pool.versions[0].post_ids)
|
||||
assert_equal([@p1.id], @pool.versions[1].post_ids)
|
||||
assert_equal([@p1.id, @p2.id], @pool.versions[2].post_ids)
|
||||
assert_equal([@p1.id, @p2.id], @pool.post_ids)
|
||||
assert_equal([@p1.id, @p2.id], @pool.reload.post_ids)
|
||||
end
|
||||
|
||||
should "update its post_ids" do
|
||||
@pool.revert_to!(@pool.versions[1])
|
||||
assert_equal([@p1.id], @pool.reload.post_ids)
|
||||
assert_equal("pool:#{@pool.id}", @p1.reload.pool_string)
|
||||
#assert_equal("", @p2.reload.pool_string)
|
||||
assert_equal([@p1.id], @pool.post_ids)
|
||||
|
||||
@pool.revert_to!(@pool.versions[0])
|
||||
assert_equal([], @pool.reload.post_ids)
|
||||
assert_equal("", @p1.reload.pool_string)
|
||||
#assert_equal("", @p2.reload.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -125,7 +114,6 @@ class PoolTest < ActiveSupport::TestCase
|
||||
context "by #attributes=" do
|
||||
setup do
|
||||
@pool.attributes = {post_ids: [@p1.id, @p2.id]}
|
||||
@pool.synchronize
|
||||
@pool.save
|
||||
end
|
||||
|
||||
@@ -138,10 +126,6 @@ class PoolTest < ActiveSupport::TestCase
|
||||
assert_equal([@p1.id], @pool.post_ids)
|
||||
end
|
||||
|
||||
should "add the pool to the post" do
|
||||
assert_equal("pool:#{@pool.id}", @p1.pool_string)
|
||||
end
|
||||
|
||||
should "increment the post count" do
|
||||
assert_equal(1, @pool.post_count)
|
||||
end
|
||||
@@ -155,10 +139,6 @@ class PoolTest < ActiveSupport::TestCase
|
||||
assert_equal([@p1.id], @pool.post_ids)
|
||||
end
|
||||
|
||||
should "not double add the pool to the post" do
|
||||
assert_equal("pool:#{@pool.id}", @p1.pool_string)
|
||||
end
|
||||
|
||||
should "not double increment the post count" do
|
||||
assert_equal(1, @pool.post_count)
|
||||
end
|
||||
@@ -171,7 +151,6 @@ class PoolTest < ActiveSupport::TestCase
|
||||
|
||||
@pool.update_attribute(:is_deleted, true)
|
||||
@pool.post_ids += [@p2.id]
|
||||
@pool.synchronize!
|
||||
@pool.save
|
||||
@pool.reload
|
||||
@p2.reload
|
||||
@@ -181,10 +160,6 @@ class PoolTest < ActiveSupport::TestCase
|
||||
assert_equal([@p1.id, @p2.id], @pool.post_ids)
|
||||
end
|
||||
|
||||
should "add the pool to the post" do
|
||||
assert_equal("pool:#{@pool.id}", @p2.pool_string)
|
||||
end
|
||||
|
||||
should "increment the post count" do
|
||||
assert_equal(2, @pool.post_count)
|
||||
end
|
||||
@@ -205,10 +180,6 @@ class PoolTest < ActiveSupport::TestCase
|
||||
assert_equal([], @pool.post_ids)
|
||||
end
|
||||
|
||||
should "remove the pool from the post" do
|
||||
assert_equal("", @p1.pool_string)
|
||||
end
|
||||
|
||||
should "update the post count" do
|
||||
assert_equal(0, @pool.post_count)
|
||||
end
|
||||
@@ -223,10 +194,6 @@ class PoolTest < ActiveSupport::TestCase
|
||||
assert_equal([@p1.id], @pool.post_ids)
|
||||
end
|
||||
|
||||
should "not affect the post" do
|
||||
assert_equal("pool:#{@pool.id}", @p1.pool_string)
|
||||
end
|
||||
|
||||
should "not affect the post count" do
|
||||
assert_equal(1, @pool.post_count)
|
||||
end
|
||||
@@ -289,29 +256,6 @@ class PoolTest < ActiveSupport::TestCase
|
||||
@pool.add!(@p3)
|
||||
end
|
||||
|
||||
context "that is synchronized" do
|
||||
setup do
|
||||
@pool.reload
|
||||
@pool.post_ids = [@p2.id]
|
||||
@pool.synchronize!
|
||||
end
|
||||
|
||||
should "update the pool" do
|
||||
@pool.reload
|
||||
assert_equal(1, @pool.post_count)
|
||||
assert_equal([@p2.id], @pool.post_ids)
|
||||
end
|
||||
|
||||
should "update the posts" do
|
||||
@p1.reload
|
||||
@p2.reload
|
||||
@p3.reload
|
||||
assert_equal("", @p1.pool_string)
|
||||
assert_equal("pool:#{@pool.id}", @p2.pool_string)
|
||||
assert_equal("", @p3.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
should "find the neighbors for the first post" do
|
||||
assert_nil(@pool.previous_post_id(@p1.id))
|
||||
assert_equal(@p2.id, @pool.next_post_id(@p1.id))
|
||||
|
||||
@@ -751,7 +751,6 @@ class PostTest < ActiveSupport::TestCase
|
||||
@post.reload
|
||||
@pool.reload
|
||||
assert_equal([@post.id], @pool.post_ids)
|
||||
assert_equal("pool:#{@pool.id}", @post.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -759,7 +758,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@pool = FactoryBot.create(:pool)
|
||||
@post = FactoryBot.create(:post, :tag_string => "aaa")
|
||||
@post.add_pool!(@pool)
|
||||
@pool.add!(@post)
|
||||
@post.tag_string = "aaa -pool:#{@pool.id}"
|
||||
@post.save
|
||||
end
|
||||
@@ -768,7 +767,6 @@ class PostTest < ActiveSupport::TestCase
|
||||
@post.reload
|
||||
@pool.reload
|
||||
assert_equal([], @pool.post_ids)
|
||||
assert_equal("", @post.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -782,7 +780,6 @@ class PostTest < ActiveSupport::TestCase
|
||||
@post.reload
|
||||
@pool.reload
|
||||
assert_equal([@post.id], @pool.post_ids)
|
||||
assert_equal("pool:#{@pool.id}", @post.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -797,7 +794,6 @@ class PostTest < ActiveSupport::TestCase
|
||||
@post.reload
|
||||
@pool.reload
|
||||
assert_equal([@post.id], @pool.post_ids)
|
||||
assert_equal("pool:#{@pool.id}", @post.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -808,7 +804,6 @@ class PostTest < ActiveSupport::TestCase
|
||||
@post.reload
|
||||
assert_not_nil(@pool)
|
||||
assert_equal([@post.id], @pool.post_ids)
|
||||
assert_equal("pool:#{@pool.id}", @post.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1661,36 +1656,6 @@ class PostTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
SqsService.any_instance.stubs(:send_message)
|
||||
end
|
||||
|
||||
context "Removing a post from a pool" do
|
||||
should "update the post's pool string" do
|
||||
post = FactoryBot.create(:post)
|
||||
pool = FactoryBot.create(:pool)
|
||||
post.add_pool!(pool)
|
||||
post.remove_pool!(pool)
|
||||
post.reload
|
||||
assert_equal("", post.pool_string)
|
||||
post.remove_pool!(pool)
|
||||
post.reload
|
||||
assert_equal("", post.pool_string)
|
||||
end
|
||||
end
|
||||
|
||||
context "Adding a post to a pool" do
|
||||
should "update the post's pool string" do
|
||||
post = FactoryBot.create(:post)
|
||||
pool = FactoryBot.create(:pool)
|
||||
post.add_pool!(pool)
|
||||
post.reload
|
||||
assert_equal("pool:#{pool.id}", post.pool_string)
|
||||
post.add_pool!(pool)
|
||||
post.reload
|
||||
assert_equal("pool:#{pool.id}", post.pool_string)
|
||||
post.remove_pool!(pool)
|
||||
post.reload
|
||||
assert_equal("", post.pool_string)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "Uploading:" do
|
||||
|
||||
@@ -73,7 +73,7 @@ class PostVersionTest < ActiveSupport::TestCase
|
||||
|
||||
should "create a version" do
|
||||
assert_equal("tagme", @post.tag_string)
|
||||
assert_equal("pool:#{@pool.id}", @post.pool_string)
|
||||
assert_equal([@pool.id], @post.pools.pluck(:id))
|
||||
|
||||
assert_equal(1, @post.versions.size)
|
||||
assert_equal("tagme", @post.versions.last.tags)
|
||||
|
||||
Reference in New Issue
Block a user