Remove unused query parameters in redirect
These actions are never called with query parameters in our application, so there's no need to use these parameters in a redirect. Note in the test I'm using the `get` method because the `patch` method wouldn't send query parameters. This doesn't mean the action can be accessed through GET requests, since controller tests don't check route verbs.
This commit is contained in:
@@ -37,12 +37,12 @@ class DebatesController < ApplicationController
|
||||
|
||||
def unmark_featured
|
||||
@debate.update!(featured_at: nil)
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_to debates_path
|
||||
end
|
||||
|
||||
def mark_featured
|
||||
@debate.update!(featured_at: Time.current)
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_to debates_path
|
||||
end
|
||||
|
||||
def disable_recommendations
|
||||
|
||||
@@ -50,4 +50,15 @@ describe DebatesController do
|
||||
end.not_to change { debate.reload.votes_for.size }
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT mark_featured" do
|
||||
it "ignores query parameters" do
|
||||
debate = create(:debate)
|
||||
sign_in create(:administrator).user
|
||||
|
||||
get :mark_featured, params: { id: debate, controller: "proposals" }
|
||||
|
||||
expect(response).to redirect_to debates_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user