diff --git a/app/controllers/favorite_groups_controller.rb b/app/controllers/favorite_groups_controller.rb index bb59b60b6..c4dcc2c10 100644 --- a/app/controllers/favorite_groups_controller.rb +++ b/app/controllers/favorite_groups_controller.rb @@ -74,6 +74,6 @@ class FavoriteGroupsController < ApplicationController end def favgroup_params - params.fetch(:favorite_group, {}).permit(%i[name post_ids is_public]) + params.fetch(:favorite_group, {}).permit(%i[name post_ids is_public], post_id_array: []) end end diff --git a/test/functional/favorite_groups_controller_test.rb b/test/functional/favorite_groups_controller_test.rb index 36a185d57..bbb85e511 100644 --- a/test/functional/favorite_groups_controller_test.rb +++ b/test/functional/favorite_groups_controller_test.rb @@ -45,11 +45,13 @@ class FavoriteGroupsControllerTest < ActionDispatch::IntegrationTest end context "update action" do - should "render" do - params = { favorite_group: { name: "foo" } } - put_auth favorite_group_path(@favgroup), @user, params: params + 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) } } + assert_redirected_to @favgroup assert_equal("foo", @favgroup.reload.name) + assert_equal(@posts.map(&:id), @favgroup.post_id_array) end end