diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/requests/api/releases_spec.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/requests/api/releases_spec.rb')
-rw-r--r-- | spec/requests/api/releases_spec.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/spec/requests/api/releases_spec.rb b/spec/requests/api/releases_spec.rb index a1aff9a6b1c..e209ad2b2d5 100644 --- a/spec/requests/api/releases_spec.rb +++ b/spec/requests/api/releases_spec.rb @@ -573,7 +573,7 @@ RSpec.describe API::Releases, feature_category: :release_orchestration do end end - describe 'GET /projects/:id/releases/:tag_name/downloads/*file_path' do + describe 'GET /projects/:id/releases/:tag_name/downloads/*direct_asset_path' do let!(:release) { create(:release, project: project, tag: 'v0.1', author: maintainer) } let!(:link) { create(:release_link, release: release, url: "#{url}#{filepath}", filepath: filepath) } let(:filepath) { '/bin/bigfile.exe' } @@ -637,6 +637,16 @@ RSpec.describe API::Releases, feature_category: :release_orchestration do end end + context 'when direct_asset_path is used' do + let(:direct_asset_path) { filepath } + + it 'redirects to the file download URL successfully' do + get api("/projects/#{project.id}/releases/v0.1/downloads#{direct_asset_path}", maintainer) + + expect(response).to redirect_to("#{url}#{direct_asset_path}") + end + end + context 'when filepath does not exists' do it 'returns 404 for maintater' do get api("/projects/#{project.id}/releases/v0.1/downloads/bin/not_existing.exe", maintainer) @@ -911,6 +921,22 @@ RSpec.describe API::Releases, feature_category: :release_orchestration do end.not_to change { Project.find_by_id(project.id).repository.tag_count } end + context 'when using `direct_asset_path` for the asset link' do + before do + params[:direct_asset_path] = params.delete(:filepath) + end + + it 'creates a new release successfully' do + expect do + post api("/projects/#{project.id}/releases", maintainer), params: params + end.to change { Release.count }.by(1) + + release = project.releases.last + + expect(release.links.last.filepath).to eq('/permanent/path/to/runbook') + end + end + context 'with protected tag' do context 'when user has access to the protected tag' do let!(:protected_tag) { create(:protected_tag, :developers_can_create, name: '*', project: project) } |