Skip to content
Snippets Groups Projects
Commit 88f2620c authored by Terri Chu's avatar Terri Chu :nail_care:
Browse files

Require search_scope for label filter

Also update specs
parent 5d5a4957
No related branches found
No related tags found
1 merge request!163353Fix bug with label_name search filter
......@@ -602,6 +602,8 @@ def filter_ids_by_feature(project_ids, user, feature)
end
def find_labels_by_name(names, options)
raise ArgumentError, 'search_scope is a required option' unless options.key?(:search_scope)
return [] unless names.any?
search_level = options[:search_scope].to_sym
......
......@@ -101,11 +101,11 @@
describe 'named queries' do
using RSpec::Parameterized::TableSyntax
where(:projects, :groups) do
[] | []
[ref(:project)] | []
[] | [ref(:group)]
[ref(:project)] | [ref(:group)]
where(:search_level, :projects, :groups) do
:global | [] | []
:project | [ref(:project)] | []
:group | [] | [ref(:group)]
:project | [ref(:project)] | [ref(:group)]
end
with_them do
......@@ -116,6 +116,7 @@
let(:base_options) do
{
current_user: user,
search_scope: search_level,
project_ids: project_ids,
group_ids: group_ids,
public_and_internal_projects: false,
......
......@@ -432,6 +432,14 @@
end
end
context 'when search_level is not provided' do
let(:options) { { label_name: label_name } }
it 'raises an exception' do
expect { by_label_ids }.to raise_exception(ArgumentError)
end
end
context 'for global search' do
let(:search_level) { :global }
......
......@@ -7,6 +7,7 @@
let(:base_options) do
{
current_user: user,
search_scope: 'global',
project_ids: project_ids,
group_ids: [],
public_and_internal_projects: false
......
......@@ -7,6 +7,7 @@
let(:base_options) do
{
current_user: user,
search_scope: 'global',
project_ids: project_ids,
group_ids: [],
public_and_internal_projects: true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment