summaryrefslogtreecommitdiff
path: root/spec/requests/api/releases_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/api/releases_spec.rb')
-rw-r--r--spec/requests/api/releases_spec.rb28
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) }