Commit b35753d8 authored by Laura Montemayor's avatar Laura Montemayor Committed by Bob Van Landuyt

Resolve timeout in admin/jobs

parent 3e2e2a8b
# 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 @@ class Admin::JobsController < Admin::ApplicationController
@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
......
---
title: Resolve timeout in admin/jobs
merge_request: 35385
author:
type: fixed
# 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
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