diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-04-07 17:06:41 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-04-07 18:34:03 +0200 |
commit | 16a2eba52b8286533d881ec1a0454ca734d41c3f (patch) | |
tree | de79410c3b3bd9eebcd09f6f193ebc77f1a2593d /spec | |
parent | 37e7fe2cc90de24c563fe70e4eff6f5d954bb630 (diff) | |
download | gitlab-ce-16a2eba52b8286533d881ec1a0454ca734d41c3f.tar.gz |
Count number of queries
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/builds_controller_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/controllers/projects/builds_controller_spec.rb b/spec/controllers/projects/builds_controller_spec.rb index 683667129e5..13208d21918 100644 --- a/spec/controllers/projects/builds_controller_spec.rb +++ b/spec/controllers/projects/builds_controller_spec.rb @@ -10,6 +10,39 @@ describe Projects::BuildsController do sign_in(user) end + describe 'GET index' do + context 'number of queries' do + before do + Ci::Build::AVAILABLE_STATUSES.each do |status| + create_build(status, status) + end + + RequestStore.begin! + end + + after do + RequestStore.end! + RequestStore.clear! + end + + def render + get :index, namespace_id: project.namespace, + project_id: project + end + + it "verifies number of queries" do + recorded = ActiveRecord::QueryRecorder.new { render } + expect(recorded.count).to be_within(5).of(8) + end + + def create_build(name, status) + pipeline = create(:ci_pipeline, project: project) + create(:ci_build, :tags, :triggered, :artifacts, + pipeline: pipeline, name: name, status: status) + end + end + end + describe 'GET status.json' do let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } |