Commit f3d65e78 authored by Stan Hu's avatar Stan Hu

Merge branch 'mc/bug/nplusone-pipelines-show' into 'master'

Improve nplusone spec for PipelinesController#show

See merge request gitlab-org/gitlab-ce!31976
parents 708881c1 ae7f5faf
...@@ -177,18 +177,22 @@ describe Projects::PipelinesController do ...@@ -177,18 +177,22 @@ describe Projects::PipelinesController do
end end
it 'does not perform N + 1 queries' do it 'does not perform N + 1 queries' do
# Set up all required variables
get_pipeline_json
control_count = ActiveRecord::QueryRecorder.new { get_pipeline_json }.count control_count = ActiveRecord::QueryRecorder.new { get_pipeline_json }.count
create_build('test', 1, 'rspec 1') first_build = pipeline.builds.first
create_build('test', 1, 'spinach 0') first_build.tag_list << [:hello, :world]
create_build('test', 1, 'spinach 1') create(:deployment, deployable: first_build)
create_build('test', 1, 'audit')
create_build('post deploy', 3, 'pages 1') second_build = pipeline.builds.second
create_build('post deploy', 3, 'pages 2') second_build.tag_list << [:docker, :ruby]
create(:deployment, deployable: second_build)
new_count = ActiveRecord::QueryRecorder.new { get_pipeline_json }.count new_count = ActiveRecord::QueryRecorder.new { get_pipeline_json }.count
expect(new_count).to be_within(12).of(control_count) expect(new_count).to be_within(1).of(control_count)
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