Commit 939a94a9 authored by drew cimino's avatar drew cimino

Move CoverageReports#index N+1 spec to controller file

parent 217bf817
......@@ -110,6 +110,20 @@ RSpec.describe Groups::Analytics::CoverageReportsController do
end
end
it 'executes the same number of queries regardless of the number of records returned' do
control = ActiveRecord::QueryRecorder.new do
get :index, params: valid_request_params
end
expect(CSV.parse(response.body).length).to eq(3)
create_daily_coverage('rspec', project, 79.0, '2020-03-10')
expect { get :index, params: valid_request_params }.not_to exceed_query_limit(control)
expect(csv_response.length).to eq(4)
end
context 'with an invalid format' do
it 'responds 404' do
get :index, params: valid_request_params.merge(format: :json)
......
......@@ -99,17 +99,6 @@ RSpec.describe Ci::DailyBuildGroupReportResultsByGroupFinder do
expect(subject).to match_array([rspec_project_coverage, karma_project_coverage, generic_coverage])
end
end
context 'when accessing projects from the result' do
it 'executes the same number of queries regardless of the number of records returned' do
control = ActiveRecord::QueryRecorder.new do
described_class.new(attributes.merge(limit: 1)).execute.map(&:project)
end
expect { subject.map(&:project) }.not_to exceed_query_limit(control)
expect(subject).to match_array([rspec_project_coverage, karma_project_coverage, generic_coverage])
end
end
end
context 'without permmissions' do
......
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