pools: store post_ids as array instead of string (fix #3979)

This commit is contained in:
evazion
2018-11-08 11:32:58 -06:00
parent 8515bf43b4
commit 115ed16a96
14 changed files with 92 additions and 113 deletions

View File

@@ -21,14 +21,14 @@ class PoolElementsControllerTest < ActionDispatch::IntegrationTest
should "add a post to a pool" do
post_auth pool_element_path, @user, params: {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}
@pool.reload
assert_equal([@post.id], @pool.post_id_array)
assert_equal([@post.id], @pool.post_ids)
end
should "add a post to a pool once and only once" do
as_user { @pool.add!(@post) }
post_auth pool_element_path, @user, params: {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}
@pool.reload
assert_equal([@post.id], @pool.post_id_array)
assert_equal([@post.id], @pool.post_ids)
end
end
@@ -40,7 +40,7 @@ class PoolElementsControllerTest < ActionDispatch::IntegrationTest
should "remove a post from a pool" do
delete_auth pool_element_path, @user, params: {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}
@pool.reload
assert_equal([], @pool.post_id_array)
assert_equal([], @pool.post_ids)
end
should "do nothing if the post is not a member of the pool" do
@@ -50,7 +50,7 @@ class PoolElementsControllerTest < ActionDispatch::IntegrationTest
end
delete_auth pool_element_path, @user, params: {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}
@pool.reload
assert_equal([], @pool.post_id_array)
assert_equal([], @pool.post_ids)
end
end
end

View File

@@ -71,9 +71,9 @@ class PoolsControllerTest < ActionDispatch::IntegrationTest
context "update action" do
should "update a pool" do
put_auth pool_path(@pool), @user, params: { pool: { name: "xyz", post_ids: @post.id.to_s }}
put_auth pool_path(@pool), @user, params: { pool: { name: "xyz", post_ids: [@post.id] }}
assert_equal("xyz", @pool.reload.name)
assert_equal(@post.id.to_s, @pool.post_ids)
assert_equal([@post.id], @pool.post_ids)
end
should "not allow updating unpermitted attributes" do
@@ -110,10 +110,10 @@ class PoolsControllerTest < ActionDispatch::IntegrationTest
setup do
as_user do
@post_2 = create(:post)
@pool = create(:pool, :post_ids => "#{@post.id}")
@pool = create(:pool, post_ids: [@post.id])
end
CurrentUser.scoped(@user, "1.2.3.4") do
@pool.update(:post_ids => "#{@post.id} #{@post_2.id}")
@pool.update(post_ids: [@post.id, @post_2.id])
end
end
@@ -123,7 +123,7 @@ class PoolsControllerTest < ActionDispatch::IntegrationTest
assert_equal([@post.id], version.post_ids)
put_auth revert_pool_path(@pool), @mod, params: {:version_id => version.id}
@pool.reload
assert_equal([@post.id], @pool.post_id_array)
assert_equal([@post.id], @pool.post_ids)
end
should "not allow reverting to a previous version of another pool" do