diff options
Diffstat (limited to 'spec/requests/api/releases_spec.rb')
-rw-r--r-- | spec/requests/api/releases_spec.rb | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/spec/requests/api/releases_spec.rb b/spec/requests/api/releases_spec.rb index c3f99872cef..0b5cc3611bd 100644 --- a/spec/requests/api/releases_spec.rb +++ b/spec/requests/api/releases_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::Releases, feature_category: :release_orchestration do +RSpec.describe API::Releases, :aggregate_failures, feature_category: :release_orchestration do let(:project) { create(:project, :repository, :private) } let(:maintainer) { create(:user) } let(:reporter) { create(:user) } @@ -422,22 +422,6 @@ RSpec.describe API::Releases, feature_category: :release_orchestration do .to eq('release-18.04.dmg') expect(json_response['assets']['links'].first['url']) .to eq('https://my-external-hosting.example.com/scrambled-url/app.zip') - expect(json_response['assets']['links'].first['external']) - .to be_truthy - end - - context 'when link is internal' do - let(:url) do - "#{project.web_url}/-/jobs/artifacts/v11.6.0-rc4/download?" \ - "job=rspec-mysql+41%2F50" - end - - it 'has external false' do - get api("/projects/#{project.id}/releases/v0.1", maintainer) - - expect(json_response['assets']['links'].first['external']) - .to be_falsy - end end end @@ -480,7 +464,7 @@ RSpec.describe API::Releases, feature_category: :release_orchestration do end context 'when specified tag is not found in the project' do - it 'returns 404 for maintater' do + it 'returns 404 for maintainer' do get api("/projects/#{project.id}/releases/non_exist_tag", maintainer) expect(response).to have_gitlab_http_status(:not_found) @@ -1665,7 +1649,11 @@ RSpec.describe API::Releases, feature_category: :release_orchestration do let_it_be(:release2) { create(:release, project: project2) } let_it_be(:release3) { create(:release, project: project3) } - context 'when authenticated as owner' do + it_behaves_like 'GET request permissions for admin mode' do + let(:path) { "/groups/#{group1.id}/releases" } + end + + context 'when authenticated as owner', :enable_admin_mode do it 'gets releases from all projects in the group' do get api("/groups/#{group1.id}/releases", admin) @@ -1715,9 +1703,14 @@ RSpec.describe API::Releases, feature_category: :release_orchestration do context 'with subgroups' do let(:group) { create(:group) } - it 'include_subgroups avoids N+1 queries' do + subject { get api("/groups/#{group.id}/releases", admin, admin_mode: true), params: query_params.merge({ include_subgroups: true }) } + + it 'include_subgroups avoids N+1 queries', :use_sql_query_cache do + subject + expect(response).to have_gitlab_http_status(:ok) + control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do - get api("/groups/#{group.id}/releases", admin), params: query_params.merge({ include_subgroups: true }) + subject end.count subgroups = create_list(:group, 10, parent: group1) @@ -1725,7 +1718,7 @@ RSpec.describe API::Releases, feature_category: :release_orchestration do create_list(:release, 10, project: projects[0], author: admin) expect do - get api("/groups/#{group.id}/releases", admin), params: query_params.merge({ include_subgroups: true }) + subject end.not_to exceed_all_query_limit(control_count) end end |