favgroups: convert post_ids from string to array.

This commit is contained in:
evazion
2020-01-14 23:33:55 -06:00
parent eecd9a183d
commit ab325c5d2b
25 changed files with 141 additions and 288 deletions

View File

@@ -33,7 +33,7 @@ class FavoriteGroupsControllerTest < ActionDispatch::IntegrationTest
context "create action" do
should "render" do
post_auth favorite_groups_path, @user, params: { favorite_group: FactoryBot.attributes_for(:favorite_group) }
assert_redirected_to favorite_groups_path
assert_redirected_to favorite_group_path(FavoriteGroup.last)
end
end
@@ -47,11 +47,11 @@ class FavoriteGroupsControllerTest < ActionDispatch::IntegrationTest
context "update action" do
should "update posts" do
@posts = create_list(:post, 2)
put_auth favorite_group_path(@favgroup), @user, params: { favorite_group: { name: "foo", post_id_array: @posts.map(&:id) } }
put_auth favorite_group_path(@favgroup), @user, params: { favorite_group: { name: "foo", post_ids: @posts.map(&:id).join(" ") } }
assert_redirected_to @favgroup
assert_equal("foo", @favgroup.reload.name)
assert_equal(@posts.map(&:id), @favgroup.post_id_array)
assert_equal(@posts.map(&:id), @favgroup.post_ids)
end
end
@@ -71,7 +71,7 @@ class FavoriteGroupsControllerTest < ActionDispatch::IntegrationTest
put_auth add_post_favorite_group_path(@favgroup), @user, params: {post_id: @post.id, format: "js"}
assert_response :success
@favgroup.reload
assert_equal([@post.id], @favgroup.post_id_array)
assert_equal([@post.id], @favgroup.post_ids)
end
end
end