summaryrefslogtreecommitdiff
path: root/spec/services/search_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/search_service_spec.rb')
-rw-r--r--spec/services/search_service_spec.rb37
1 files changed, 33 insertions, 4 deletions
diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb
index fc613a6224a..40fb257b23e 100644
--- a/spec/services/search_service_spec.rb
+++ b/spec/services/search_service_spec.rb
@@ -18,9 +18,10 @@ RSpec.describe SearchService do
let(:group_project) { create(:project, group: accessible_group, name: 'group_project') }
let(:public_project) { create(:project, :public, name: 'public_project') }
+ let(:page) { 1 }
let(:per_page) { described_class::DEFAULT_PER_PAGE }
- subject(:search_service) { described_class.new(user, search: search, scope: scope, page: 1, per_page: per_page) }
+ subject(:search_service) { described_class.new(user, search: search, scope: scope, page: page, per_page: per_page) }
before do
accessible_project.add_maintainer(user)
@@ -242,10 +243,10 @@ RSpec.describe SearchService do
end
describe '#search_objects' do
- context 'handling per_page param' do
- let(:search) { '' }
- let(:scope) { nil }
+ let(:search) { '' }
+ let(:scope) { nil }
+ describe 'per_page: parameter' do
context 'when nil' do
let(:per_page) { nil }
@@ -312,6 +313,34 @@ RSpec.describe SearchService do
end
end
+ describe 'page: parameter' do
+ context 'when < 1' do
+ let(:page) { 0 }
+
+ it "defaults to 1" do
+ expect_any_instance_of(Gitlab::SearchResults)
+ .to receive(:objects)
+ .with(anything, hash_including(page: 1))
+ .and_call_original
+
+ subject.search_objects
+ end
+ end
+
+ context 'when nil' do
+ let(:page) { nil }
+
+ it "defaults to 1" do
+ expect_any_instance_of(Gitlab::SearchResults)
+ .to receive(:objects)
+ .with(anything, hash_including(page: 1))
+ .and_call_original
+
+ subject.search_objects
+ end
+ end
+ end
+
context 'with accessible project_id' do
it 'returns objects in the project' do
search_objects = described_class.new(