diff --git a/app/controllers/admin/jobs_controller.rb b/app/controllers/admin/jobs_controller.rb index a3a18a115e966e57d8642472be670693df7e35a9..7b50a45a9cddbd19e28c0a63e47d3764e55a5f78 100644 --- a/app/controllers/admin/jobs_controller.rb +++ b/app/controllers/admin/jobs_controller.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class Admin::JobsController < Admin::ApplicationController + BUILDS_PER_PAGE = 30 + def index # We need all builds for tabs counters @all_builds = Ci::JobsFinder.new(current_user: current_user).execute @@ -8,7 +10,7 @@ def index @scope = params[:scope] @builds = Ci::JobsFinder.new(current_user: current_user, params: params).execute @builds = @builds.eager_load_everything - @builds = @builds.page(params[:page]).per(30) + @builds = @builds.page(params[:page]).per(BUILDS_PER_PAGE).without_count end def cancel_all diff --git a/changelogs/unreleased/lm-resolve-timeout.yml b/changelogs/unreleased/lm-resolve-timeout.yml new file mode 100644 index 0000000000000000000000000000000000000000..d4a34db9ea9e5c36d030ec961848df2a8acd2325 --- /dev/null +++ b/changelogs/unreleased/lm-resolve-timeout.yml @@ -0,0 +1,5 @@ +--- +title: Resolve timeout in admin/jobs +merge_request: 35385 +author: +type: fixed diff --git a/spec/controllers/admin/jobs_controller_spec.rb b/spec/controllers/admin/jobs_controller_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..2d1482f40d4daad477d12be84009bf2dbb03efb3 --- /dev/null +++ b/spec/controllers/admin/jobs_controller_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Admin::JobsController do + describe 'GET #index' do + context 'with an authenticated admin user' do + it 'paginates builds without a total count', :aggregate_failures do + stub_const("Admin::JobsController::BUILDS_PER_PAGE", 1) + + sign_in(create(:admin)) + create_list(:ci_build, 2) + + get :index + + expect(response).to have_gitlab_http_status(:ok) + expect(assigns(:builds)).to be_a(Kaminari::PaginatableWithoutCount) + expect(assigns(:builds).count).to be(1) + end + end + + context 'without admin access' do + it 'returns `not_found`' do + sign_in(create(:user)) + + get :index + + expect(response).to have_gitlab_http_status(:not_found) + end + end + end +end