Skip to content

Commit

Permalink
Merge pull request #1175 from alphagov/fix-bug
Browse files Browse the repository at this point in the history
Fix bug when filtering anonymous feedback
  • Loading branch information
MuriloDalRi authored Sep 5, 2023
2 parents 2b3dd63 + 05b4644 commit cdc7c98
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/anonymous_feedback_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ def clean_paths
if params[:path].present?
params[:paths] = [params[:path]]
elsif params[:paths] && params[:paths].instance_of?(String)
params[:paths] = params[:paths].split(",").map(&:strip)
params[:paths] = if params[:paths].empty?
["/"]
else
params[:paths].split(",").map(&:strip)
end
end
end

Expand Down
13 changes: 13 additions & 0 deletions spec/controllers/anonymous_feedback_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,19 @@
end
end

it "normalises empty path before talking to the api" do
api_request = stub_support_api_anonymous_feedback(
hash_including("path_prefixes" => ["/"]),
"results" => [],
"pages" => 0,
"current_page" => 1,
)

get :index, params: { paths: "" }

expect(api_request).to have_been_made
end

it "normalises the path before talking to the api" do
api_request = stub_support_api_anonymous_feedback(
hash_including("path_prefixes" => ["/done/apply-carers-allowance"]),
Expand Down

0 comments on commit cdc7c98

Please sign in to comment.