Commit b2de4a50 authored by Micael Bergeron's avatar Micael Bergeron

Reset the search filters upon a scope change

Whenever a user changes the search scope from the search results tabs,
the search filters will be reset to their default (i.e. ANY) value.
parent c88b5e3b
# frozen_string_literal: true
module SearchHelper
SEARCH_PERMITTED_PARAMS = [
SEARCH_GENERIC_PARAMS = [
:search,
:scope,
:project_id,
......@@ -9,8 +9,6 @@ module SearchHelper
:repository_ref,
:snippets,
:sort,
:state,
:confidential,
:force_search_results
].freeze
......@@ -255,7 +253,7 @@ module SearchHelper
search_params = params
.merge(search)
.merge({ scope: scope })
.permit(SEARCH_PERMITTED_PARAMS)
.permit(SEARCH_GENERIC_PARAMS)
if @scope == scope
li_class = 'active'
......
---
title: Reset search results filters whenever a user changes scope.
merge_request: 45808
author:
type: fixed
......@@ -373,6 +373,19 @@ RSpec.describe SearchHelper do
expect(link).to have_link('Projects', href: search_path(scope: 'projects', search: 'hello', project_id: 23))
end
it 'restricts the params' do
expect(self).to receive(:params).and_return(
ActionController::Parameters.new(
search: 'hello',
unknown: 42
)
)
link = search_filter_link('projects', 'Projects')
expect(link).to have_link('Projects', href: search_path(scope: 'projects', search: 'hello'))
end
it 'assigns given data attributes on the list container' do
link = search_filter_link('projects', 'Projects', data: { foo: 'bar' })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment