From 9839f97f9ea38d8e120d5a1a1df6f2804c63b2a0 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 22 Sep 2019 15:19:23 -0500 Subject: [PATCH] Fix #4176: Ordering favorite groups errors out. --- app/controllers/favorite_groups_controller.rb | 2 +- test/functional/favorite_groups_controller_test.rb | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) 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