diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 15:09:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 15:09:42 +0300 |
commit | 729e3765d5feb762df1ccfbc228a8dd4662aa3f9 (patch) | |
tree | f326420fc64999c6bcc28816ed54f0972fb46459 /spec/requests/api/releases_spec.rb | |
parent | 6f7881ee9dcec34141a8f34fc814b56b366d2b48 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/releases_spec.rb')
-rw-r--r-- | spec/requests/api/releases_spec.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/spec/requests/api/releases_spec.rb b/spec/requests/api/releases_spec.rb index 41999ca6e60..e66e999dc27 100644 --- a/spec/requests/api/releases_spec.rb +++ b/spec/requests/api/releases_spec.rb @@ -104,6 +104,21 @@ describe API::Releases do expect(json_response.first['upcoming_release']).to eq(false) end + it 'avoids N+1 queries' do + create(:release, :with_evidence, project: project, tag: 'v0.1', author: maintainer) + + control_count = ActiveRecord::QueryRecorder.new do + get api("/projects/#{project.id}/releases", maintainer) + end.count + + create(:release, :with_evidence, project: project, tag: 'v0.1', author: maintainer) + create(:release, :with_evidence, project: project, tag: 'v0.1', author: maintainer) + + expect do + get api("/projects/#{project.id}/releases", maintainer) + end.not_to exceed_query_limit(control_count) + end + context 'when tag does not exist in git repository' do let!(:release) { create(:release, project: project, tag: 'v1.1.5') } @@ -725,7 +740,7 @@ describe API::Releases do end it 'does not create an Evidence object', :sidekiq_inline do - expect { subject }.not_to change(Evidence, :count) + expect { subject }.not_to change(Releases::Evidence, :count) end it 'is a historical release' do @@ -755,7 +770,7 @@ describe API::Releases do end it 'creates Evidence', :sidekiq_inline do - expect { subject }.to change(Evidence, :count).by(1) + expect { subject }.to change(Releases::Evidence, :count).by(1) end it 'is not a historical release' do @@ -785,7 +800,7 @@ describe API::Releases do end it 'creates Evidence', :sidekiq_inline do - expect { subject }.to change(Evidence, :count).by(1) + expect { subject }.to change(Releases::Evidence, :count).by(1) end it 'is not a historical release' do |