diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-06-07 15:57:40 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-06-07 15:57:40 +0300 |
commit | 013285e951503d9cea8e0c0d0b8a3ac139ff6415 (patch) | |
tree | d7d65a32d671a02e5ae5f2847202c5b804c25846 /spec/features | |
parent | d27db3eaede283f1061d4ad433e6d92680343e72 (diff) | |
parent | c698f10942ebdf44d0c2a6559277bc6a89d26c5b (diff) |
Merge branch 'issue_27166_2' into 'master'
Avoid repeated queries for pipeline builds on merge requests
See merge request !11888
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/merge_requests/mini_pipeline_graph_spec.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/spec/features/merge_requests/mini_pipeline_graph_spec.rb b/spec/features/merge_requests/mini_pipeline_graph_spec.rb index 3ceb91d951d..3a11ea3c8b2 100644 --- a/spec/features/merge_requests/mini_pipeline_graph_spec.rb +++ b/spec/features/merge_requests/mini_pipeline_graph_spec.rb @@ -12,13 +12,39 @@ feature 'Mini Pipeline Graph', :js, :feature do build.run login_as(user) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit_merge_request + end + + def visit_merge_request(format = :html) + visit namespace_project_merge_request_path(project.namespace, project, merge_request, format: format) end it 'should display a mini pipeline graph' do expect(page).to have_selector('.mr-widget-pipeline-graph') end + context 'as json' do + let(:artifacts_file1) { fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') } + let(:artifacts_file2) { fixture_file_upload(Rails.root + 'spec/fixtures/dk.png', 'image/png') } + + before do + create(:ci_build, pipeline: pipeline, artifacts_file: artifacts_file1) + create(:ci_build, pipeline: pipeline, when: 'manual') + end + + it 'avoids repeated database queries' do + before = ActiveRecord::QueryRecorder.new { visit_merge_request(:json) } + + create(:ci_build, pipeline: pipeline, artifacts_file: artifacts_file2) + create(:ci_build, pipeline: pipeline, when: 'manual') + + after = ActiveRecord::QueryRecorder.new { visit_merge_request(:json) } + + expect(before.count).to eq(after.count) + expect(before.cached_count).to eq(after.cached_count) + end + end + describe 'build list toggle' do let(:toggle) do find('.mini-pipeline-graph-dropdown-toggle') |