summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-08-19 21:52:56 +0000
committerStan Hu <stanhu@gmail.com>2019-08-19 21:52:56 +0000
commitf3d65e78bc3b3d65d3ee445bc40bae49ec29a966 (patch)
tree29d562925da593e74506103351d34a1cb15c422f
parent708881c182f228cd8c1c5d3cef42fd21d232f897 (diff)
parentae7f5faf675848cd561687548757cee6e647ab14 (diff)
downloadgitlab-ce-f3d65e78bc3b3d65d3ee445bc40bae49ec29a966.tar.gz
Merge branch 'mc/bug/nplusone-pipelines-show' into 'master'
Improve nplusone spec for PipelinesController#show See merge request gitlab-org/gitlab-ce!31976
-rw-r--r--spec/controllers/projects/pipelines_controller_spec.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb
index 9a50ea79f5e..089d06e11eb 100644
--- a/spec/controllers/projects/pipelines_controller_spec.rb
+++ b/spec/controllers/projects/pipelines_controller_spec.rb
@@ -177,18 +177,22 @@ describe Projects::PipelinesController do
end
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
- create_build('test', 1, 'rspec 1')
- create_build('test', 1, 'spinach 0')
- create_build('test', 1, 'spinach 1')
- create_build('test', 1, 'audit')
- create_build('post deploy', 3, 'pages 1')
- create_build('post deploy', 3, 'pages 2')
+ first_build = pipeline.builds.first
+ first_build.tag_list << [:hello, :world]
+ create(:deployment, deployable: first_build)
+
+ second_build = pipeline.builds.second
+ second_build.tag_list << [:docker, :ruby]
+ create(:deployment, deployable: second_build)
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