Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/lib/gitlab/search_results_sorted_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/lib/gitlab/search_results_sorted_shared_examples.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/support/shared_examples/lib/gitlab/search_results_sorted_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/search_results_sorted_shared_examples.rb
index eafb49cef71..e4f09dfa0b0 100644
--- a/spec/support/shared_examples/lib/gitlab/search_results_sorted_shared_examples.rb
+++ b/spec/support/shared_examples/lib/gitlab/search_results_sorted_shared_examples.rb
@@ -33,3 +33,21 @@ RSpec.shared_examples 'search results sorted' do
end
end
end
+
+RSpec.shared_examples 'search results sorted by popularity' do
+ context 'sort: popularity_desc' do
+ let(:sort) { 'popularity_desc' }
+
+ it 'sorts results by upvotes' do
+ expect(results_popular.objects(scope).map(&:id)).to eq([popular_result.id, less_popular_result.id, non_popular_result.id])
+ end
+ end
+
+ context 'sort: popularity_asc' do
+ let(:sort) { 'popularity_asc' }
+
+ it 'sorts results by created_at' do
+ expect(results_popular.objects(scope).map(&:id)).to eq([non_popular_result.id, less_popular_result.id, popular_result.id])
+ end
+ end
+end