summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/commits_spec.rb26
1 files changed, 25 insertions, 1 deletions
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb
index 3932abd20cc..bcc27a80cf8 100644
--- a/spec/requests/api/commits_spec.rb
+++ b/spec/requests/api/commits_spec.rb
@@ -249,6 +249,18 @@ RSpec.describe API::Commits, feature_category: :source_code_management do
end
end
+ context 'when per_page is over 100' do
+ let(:per_page) { 101 }
+
+ it 'returns 100 commits (maximum)' do
+ expect(Gitlab::Git::Commit).to receive(:where).with(
+ hash_including(ref: ref_name, limit: 100, offset: 0)
+ )
+
+ request
+ end
+ end
+
context 'when pagination params are invalid' do
let_it_be(:project) { create(:project, :repository) }
@@ -279,7 +291,7 @@ RSpec.describe API::Commits, feature_category: :source_code_management do
where(:page, :per_page, :error_message, :status) do
0 | nil | nil | :success
- -10 | nil | nil | :internal_server_error
+ -10 | nil | nil | :success
'a' | nil | 'page is invalid' | :bad_request
nil | 0 | 'per_page has a value not allowed' | :bad_request
nil | -1 | nil | :success
@@ -297,6 +309,18 @@ RSpec.describe API::Commits, feature_category: :source_code_management do
end
end
end
+
+ context 'when per_page is below 0' do
+ let(:per_page) { -100 }
+
+ it 'returns 20 commits (default)' do
+ expect(Gitlab::Git::Commit).to receive(:where).with(
+ hash_including(ref: ref_name, limit: 20, offset: 0)
+ )
+
+ request
+ end
+ end
end
end
end