Commit 02da71f3 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Change the number of pipelines per page to 15

Changelog: changed
parent c5c32ad2
......@@ -52,7 +52,8 @@ class Projects::CommitController < Projects::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def pipelines
@pipelines = @commit.pipelines.order(id: :desc)
@pipelines = @pipelines.where(ref: params[:ref]).page(params[:page]).per(30) if params[:ref]
@pipelines = @pipelines.where(ref: params[:ref]) if params[:ref]
@pipelines = @pipelines.page(params[:page])
respond_to do |format|
format.html
......
......@@ -167,7 +167,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
def pipelines
set_pipeline_variables
@pipelines = @pipelines.page(params[:page]).per(30)
@pipelines = @pipelines.page(params[:page])
Gitlab::PollingInterval.set_header(response, interval: 10_000)
......
......@@ -42,7 +42,6 @@ class Projects::PipelinesController < Projects::ApplicationController
.new(project, current_user, index_params)
.execute
.page(params[:page])
.per(20)
@pipelines_count = limited_pipelines_count(project)
......
......@@ -29,6 +29,8 @@ module Ci
BridgeStatusError = Class.new(StandardError)
paginates_per 15
sha_attribute :source_sha
sha_attribute :target_sha
......
......@@ -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
......
......@@ -860,6 +860,20 @@ RSpec.describe Projects::MergeRequestsController do
end
end
end
context 'with pagination' do
before do
create(:ci_pipeline, project: merge_request.source_project, ref: merge_request.source_branch, sha: merge_request.diff_head_sha)
end
it 'paginates the result' do
allow(Ci::Pipeline).to receive(:default_per_page).and_return(1)
get :pipelines, params: { namespace_id: project.namespace.to_param, project_id: project, id: merge_request.iid }, format: :json
expect(json_response['pipelines'].count).to eq(1)
end
end
end
describe 'GET context commits' do
......
......@@ -66,6 +66,14 @@ RSpec.describe Projects::PipelinesController do
expect(json_response['pipelines'][0]).not_to include('coverage')
end
it 'paginates the result' do
allow(Ci::Pipeline).to receive(:default_per_page).and_return(2)
get_pipelines_index_json
check_pipeline_response(returned: 2, all: 6)
end
context 'when performing gitaly calls', :request_store do
it 'limits the Gitaly requests' do
# Isolate from test preparation (Repository#exists? is also cached in RequestStore)
......
......@@ -11,6 +11,10 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
let_it_be(:namespace) { create_default(:namespace).freeze }
let_it_be(:project) { create_default(:project, :repository).freeze }
it 'paginates 15 pipeleines per page' do
expect(described_class.default_per_page).to eq(15)
end
it_behaves_like 'having unique enum values'
it { is_expected.to belong_to(:project) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment