Commit a5365622 authored by Dmitry Gruzd's avatar Dmitry Gruzd

Merge branch '332631-change-feature-flag-to-no-actor' into 'master'

Move advanced_search_multi_project_select FF to user actor

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