summaryrefslogtreecommitdiff
path: root/spec/controllers/projects/commit_controller_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/projects/commit_controller_spec.rb')
-rw-r--r--spec/controllers/projects/commit_controller_spec.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb
index c650d145bef..16bb33e95c8 100644
--- a/spec/controllers/projects/commit_controller_spec.rb
+++ b/spec/controllers/projects/commit_controller_spec.rb
@@ -483,7 +483,7 @@ RSpec.describe Projects::CommitController do
end
context 'when rendering a JSON format' do
- it 'responds with serialized pipelines' do
+ it 'responds with serialized pipelines', :aggregate_failures do
get_pipelines(id: commit.id, format: :json)
expect(response).to be_ok
@@ -491,6 +491,26 @@ RSpec.describe Projects::CommitController do
expect(json_response['count']['all']).to eq 1
expect(response).to include_pagination_headers
end
+
+ context 'with pagination' do
+ let!(:extra_pipeline) { create(:ci_pipeline, project: project, ref: project.default_branch, sha: commit.sha, status: :running) }
+
+ it 'paginates the result when ref is blank' do
+ allow(Ci::Pipeline).to receive(:default_per_page).and_return(1)
+
+ get_pipelines(id: commit.id, format: :json)
+
+ expect(json_response['pipelines'].count).to eq(1)
+ end
+
+ it 'paginates the result when ref is present' do
+ allow(Ci::Pipeline).to receive(:default_per_page).and_return(1)
+
+ get_pipelines(id: commit.id, ref: project.default_branch, format: :json)
+
+ expect(json_response['pipelines'].count).to eq(1)
+ end
+ end
end
end
end