diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-17 00:08:53 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-17 00:08:53 +0300 |
commit | cfaf1cca4403b826af2286b1ab0a69ad01c58738 (patch) | |
tree | 89a4456977185bbe993ea091a3f5b13412bc811a /spec/lib/gitlab/project_search_results_spec.rb | |
parent | 57e39452d861ff01ccd4c09243c0bd2a0947ad07 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/project_search_results_spec.rb')
-rw-r--r-- | spec/lib/gitlab/project_search_results_spec.rb | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb index ae4c14e4deb..d206d31eb96 100644 --- a/spec/lib/gitlab/project_search_results_spec.rb +++ b/spec/lib/gitlab/project_search_results_spec.rb @@ -31,7 +31,7 @@ describe Gitlab::ProjectSearchResults do let(:results) { described_class.new(user, project, query) } where(:scope, :count_method, :expected) do - 'blobs' | :blobs_count | '1234' + 'blobs' | :limited_blobs_count | max_limited_count 'notes' | :limited_notes_count | max_limited_count 'wiki_blobs' | :wiki_blobs_count | '1234' 'commits' | :commits_count | '1234' @@ -141,9 +141,9 @@ describe Gitlab::ProjectSearchResults do describe 'blob search' do let(:project) { create(:project, :public, :repository) } + let(:blob_type) { 'blobs' } it_behaves_like 'general blob search', 'repository', 'blobs' do - let(:blob_type) { 'blobs' } let(:disabled_project) { create(:project, :public, :repository, :repository_disabled) } let(:private_project) { create(:project, :public, :repository, :repository_private) } let(:expected_file_by_path) { 'files/images/wm.svg' } @@ -151,9 +151,36 @@ describe Gitlab::ProjectSearchResults do end it_behaves_like 'blob search repository ref', 'project' do - let(:blob_type) { 'blobs' } let(:entity) { project } end + + context 'pagination' do + let(:per_page) { 20 } + let(:count_limit) { described_class::COUNT_LIMIT } + let(:file_finder) { instance_double('Gitlab::FileFinder') } + let(:results) { described_class.new(user, project, query, per_page: per_page) } + let(:repository_ref) { 'master' } + + before do + allow(file_finder).to receive(:find).and_return([]) + expect(Gitlab::FileFinder).to receive(:new).with(project, repository_ref).and_return(file_finder) + end + + it 'limits search results based on the first page' do + expect(file_finder).to receive(:find).with(query, content_match_cutoff: count_limit) + results.objects(blob_type, 1) + end + + it 'limits search results based on the second page' do + expect(file_finder).to receive(:find).with(query, content_match_cutoff: count_limit + per_page) + results.objects(blob_type, 2) + end + + it 'limits search results based on the third page' do + expect(file_finder).to receive(:find).with(query, content_match_cutoff: count_limit + per_page * 2) + results.objects(blob_type, 3) + end + end end describe 'wiki search' do |