Fix #4176: Ordering favorite groups errors out.
This commit is contained in:
@@ -74,6 +74,6 @@ class FavoriteGroupsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def favgroup_params
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -45,11 +45,13 @@ class FavoriteGroupsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "update action" do
|
context "update action" do
|
||||||
should "render" do
|
should "update posts" do
|
||||||
params = { favorite_group: { name: "foo" } }
|
@posts = create_list(:post, 2)
|
||||||
put_auth favorite_group_path(@favgroup), @user, params: params
|
put_auth favorite_group_path(@favgroup), @user, params: { favorite_group: { name: "foo", post_id_array: @posts.map(&:id) } }
|
||||||
|
|
||||||
assert_redirected_to @favgroup
|
assert_redirected_to @favgroup
|
||||||
assert_equal("foo", @favgroup.reload.name)
|
assert_equal("foo", @favgroup.reload.name)
|
||||||
|
assert_equal(@posts.map(&:id), @favgroup.post_id_array)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user