Commit 6e48a8e0 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch...

Merge branch '263249-project_finder_similarity_sort-enable-project-search-by-similarity-remove-flag' into 'master'

Remove project_finder_similarity_sort feature flag

See merge request gitlab-org/gitlab!64361
parents 636fd258 dda10f5a
......@@ -55,7 +55,7 @@ class ProjectsFinder < UnionFinder
collection = Project.wrap_with_cte(collection) if use_cte
collection = filter_projects(collection)
if params[:sort] == 'similarity' && params[:search] && Feature.enabled?(:project_finder_similarity_sort, current_user)
if params[:sort] == 'similarity' && params[:search]
collection.sorted_by_similarity_desc(params[:search])
else
sort(collection)
......
---
name: project_finder_similarity_sort
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/43136
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/263249
milestone: '13.5'
type: development
group: group::threat insights
default_enabled: false
......@@ -31,10 +31,6 @@ RSpec.describe ProjectsFinder do
let(:use_cte) { true }
let(:finder) { described_class.new(params: params.merge(use_cte: use_cte), current_user: current_user, project_ids_relation: project_ids_relation) }
before do
stub_feature_flags(project_finder_similarity_sort: false)
end
subject { finder.execute }
shared_examples 'ProjectFinder#execute examples' do
......@@ -368,32 +364,28 @@ RSpec.describe ProjectsFinder do
end
describe 'sorting' do
let_it_be(:more_projects) do
[
create(:project, :internal, group: group, name: 'projA', path: 'projA'),
create(:project, :internal, group: group, name: 'projABC', path: 'projABC'),
create(:project, :internal, group: group, name: 'projAB', path: 'projAB')
]
end
context 'when sorting by a field' do
let(:params) { { sort: 'name_asc' } }
it { is_expected.to eq([internal_project, public_project]) }
it { is_expected.to eq(([internal_project, public_project] + more_projects).sort_by { |p| p[:name] }) }
end
context 'when sorting by similarity' do
let(:params) { { sort: 'similarity', search: 'pro' } }
let_it_be(:internal_project2) do
create(:project, :internal, group: group, name: 'projA', path: 'projA')
end
let_it_be(:internal_project3) do
create(:project, :internal, group: group, name: 'projABC', path: 'projABC')
end
let_it_be(:internal_project4) do
create(:project, :internal, group: group, name: 'projAB', path: 'projAB')
end
before do
stub_feature_flags(project_finder_similarity_sort: current_user)
end
it { is_expected.to eq([more_projects[0], more_projects[2], more_projects[1]]) }
end
it { is_expected.to eq([internal_project2, internal_project4, internal_project3]) }
context 'when no sort is provided' do
it { is_expected.to eq(([internal_project, public_project] + more_projects).sort_by { |p| p[:id] }.reverse) }
end
end
......
......@@ -27,10 +27,6 @@ RSpec.describe Resolvers::ProjectsResolver do
private_group.add_developer(user)
end
before do
stub_feature_flags(project_finder_similarity_sort: false)
end
context 'when user is not logged in' do
let(:current_user) { nil }
......@@ -83,6 +79,7 @@ RSpec.describe Resolvers::ProjectsResolver do
context 'when user is logged in' do
let(:current_user) { user }
let(:visible_projecs) { [project, other_project, group_project, private_project, private_group_project] }
context 'when no filters are applied' do
it 'returns all visible projects for the user' do
......@@ -129,21 +126,24 @@ RSpec.describe Resolvers::ProjectsResolver do
end
end
context 'when sort is similarity' do
context 'when sorting' do
let_it_be(:named_project1) { create(:project, :public, name: 'projAB', path: 'projAB') }
let_it_be(:named_project2) { create(:project, :public, name: 'projABC', path: 'projABC') }
let_it_be(:named_project3) { create(:project, :public, name: 'projA', path: 'projA') }
let_it_be(:named_projects) { [named_project1, named_project2, named_project3] }
let(:filters) { { search: 'projA', sort: 'similarity' } }
it 'returns projects in order of similarity to search' do
stub_feature_flags(project_finder_similarity_sort: current_user)
context 'when sorting by similarity' do
let(:filters) { { search: 'projA', sort: 'similarity' } }
is_expected.to eq([named_project3, named_project1, named_project2])
it 'returns projects in order of similarity to search' do
is_expected.to eq([named_project3, named_project1, named_project2])
end
end
it 'returns projects in any order if flag is off' do
is_expected.to match_array([named_project3, named_project1, named_project2])
context 'when no sort is provided' do
it 'returns projects in descending order by id' do
is_expected.to match_array((visible_projecs + named_projects).sort_by { |p| p[:id]}.reverse )
end
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