summaryrefslogtreecommitdiff
path: root/spec/finders/projects_finder_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/finders/projects_finder_spec.rb')
-rw-r--r--spec/finders/projects_finder_spec.rb32
1 files changed, 30 insertions, 2 deletions
diff --git a/spec/finders/projects_finder_spec.rb b/spec/finders/projects_finder_spec.rb
index 8ae19757c25..2d712bd44ce 100644
--- a/spec/finders/projects_finder_spec.rb
+++ b/spec/finders/projects_finder_spec.rb
@@ -31,6 +31,10 @@ RSpec.describe ProjectsFinder, :do_not_mock_admin_mode 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
@@ -304,9 +308,33 @@ RSpec.describe ProjectsFinder, :do_not_mock_admin_mode do
end
describe 'sorting' do
- let(:params) { { sort: 'name_asc' } }
+ context 'when sorting by a field' do
+ let(:params) { { sort: 'name_asc' } }
+
+ it { is_expected.to eq([internal_project, public_project]) }
+ end
- it { is_expected.to eq([internal_project, public_project]) }
+ 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: true)
+ end
+
+ it { is_expected.to eq([internal_project2, internal_project4, internal_project3]) }
+ end
end
describe 'with admin user' do