Commit 1d43d927 authored by Terri Chu's avatar Terri Chu

Move advanced_search_multi_project_select FF to user actor

Changelog: changed
EE: true
parent 19e391ba
......@@ -2,7 +2,7 @@
name: advanced_search_multi_project_select
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62606
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/333011
milestone: '14.0'
milestone: '14.4'
type: development
group: group::global search
default_enabled: false
......@@ -37,7 +37,7 @@ module EE
def projects
strong_memoize(:projects) do
next unless params[:project_ids].present? && params[:project_ids].is_a?(String)
next unless group.present? && ::Feature.enabled?(:advanced_search_multi_project_select, group)
next unless ::Feature.enabled?(:advanced_search_multi_project_select, current_user, default_enabled: :yaml)
project_ids = params[:project_ids].split(',')
the_projects = ::Project.where(id: project_ids)
......
......@@ -221,20 +221,15 @@ RSpec.describe SearchService do
describe '#projects' do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:accessible_project) { create(:project, :public, namespace: group) }
let_it_be(:inaccessible_project) { create(:project, :private, namespace: group) }
before do
stub_feature_flags(advanced_search_multi_project_select: group)
end
let_it_be(:accessible_project) { create(:project, :public) }
let_it_be(:inaccessible_project) { create(:project, :private) }
context 'when all projects are accessible' do
let_it_be(:accessible_project_2) { create(:project, :public, namespace: group) }
let_it_be(:accessible_project_2) { create(:project, :public) }
it 'returns the project' do
project_ids = [accessible_project.id, accessible_project_2.id].join(',')
projects = described_class.new(user, group_id: group.id, project_ids: project_ids).projects
projects = described_class.new(user, project_ids: project_ids).projects
expect(projects).to match_array [accessible_project, accessible_project_2]
end
......@@ -243,21 +238,21 @@ RSpec.describe SearchService do
search_project = create :project
search_project.add_guest(user)
project_ids = [accessible_project.id, accessible_project_2.id, search_project.id].join(',')
projects = described_class.new(user, group_id: group.id, project_ids: project_ids).projects
projects = described_class.new(user, project_ids: project_ids).projects
expect(projects).to match_array [accessible_project, accessible_project_2, search_project]
end
it 'handles spaces in the param' do
project_ids = [accessible_project.id, accessible_project_2.id].join(', ')
projects = described_class.new(user, group_id: group.id, project_ids: project_ids).projects
projects = described_class.new(user, project_ids: project_ids).projects
expect(projects).to match_array [accessible_project, accessible_project_2]
end
it 'returns nil if projects param is not a String' do
project_ids = accessible_project.id
projects = described_class.new(user, group_id: group.id, project_ids: project_ids).projects
projects = described_class.new(user, project_ids: project_ids).projects
expect(projects).to be_nil
end
......@@ -266,7 +261,7 @@ RSpec.describe SearchService do
context 'when some projects are accessible' do
it 'returns only accessible projects' do
project_ids = [accessible_project.id, inaccessible_project.id].join(',')
projects = described_class.new(user, group_id: group.id, project_ids: project_ids).projects
projects = described_class.new(user, project_ids: project_ids).projects
expect(projects).to match_array [accessible_project]
end
......@@ -275,7 +270,7 @@ RSpec.describe SearchService do
context 'when no projects are accessible' do
it 'returns nil' do
project_ids = "#{inaccessible_project.id}"
projects = described_class.new(user, group_id: group.id, project_ids: project_ids).projects
projects = described_class.new(user, project_ids: project_ids).projects
expect(projects).to be_nil
end
......@@ -289,23 +284,14 @@ RSpec.describe SearchService do
end
end
context 'when no group_id provided' do
it 'returns nil' do
project_ids = "#{accessible_project.id}"
projects = described_class.new(user, project_ids: project_ids).projects
expect(projects).to be_nil
end
end
context 'when the advanced_search_multi_project_select feature is not enabled for the group' do
context 'when the advanced_search_multi_project_select feature is not enabled' do
before do
stub_feature_flags(advanced_search_multi_project_select: false)
end
it 'returns nil' do
project_ids = "#{accessible_project.id}"
projects = described_class.new(user, group_id: group.id, project_ids: project_ids).projects
projects = described_class.new(user, project_ids: project_ids).projects
expect(projects).to be_nil
end
......
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