Commit d993480b authored by Igor Drozdov's avatar Igor Drozdov

Merge branch '230698-fix-create-release-asset-link' into 'master'

Fix creating release asset links when using the API

See merge request gitlab-org/gitlab!37557
parents 35204cc1 e7a0a919
---
title: Fix creating release asset links when using the API
merge_request: 37557
author:
type: fixed
......@@ -40,7 +40,7 @@ module API
requires :name, type: String, desc: 'The name of the link'
requires :url, type: String, desc: 'The URL of the link'
optional :filepath, type: String, desc: 'The filepath of the link'
optional :link_type, type: String, desc: 'The link type'
optional :link_type, type: String, desc: 'The link type, one of: "runbook", "image", "package" or "other"'
end
post 'links' do
authorize! :create_release, release
......
......@@ -50,8 +50,10 @@ module API
optional :ref, type: String, desc: 'The commit sha or branch name'
optional :assets, type: Hash do
optional :links, type: Array do
requires :name, type: String
requires :url, type: String
requires :name, type: String, desc: 'The name of the link'
requires :url, type: String, desc: 'The URL of the link'
optional :filepath, type: String, desc: 'The filepath of the link'
optional :link_type, type: String, desc: 'The link type, one of: "runbook", "image", "package" or "other"'
end
end
optional :milestones, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'The titles of the related milestones', default: []
......
......@@ -420,7 +420,17 @@ RSpec.describe API::Releases do
{
name: 'New release',
tag_name: 'v0.1',
description: 'Super nice release'
description: 'Super nice release',
assets: {
links: [
{
name: 'An example runbook link',
url: 'https://example.com/runbook',
link_type: 'runbook',
filepath: '/permanent/path/to/runbook'
}
]
}
}
end
......@@ -435,9 +445,17 @@ RSpec.describe API::Releases do
post api("/projects/#{project.id}/releases", maintainer), params: params
end.to change { Release.count }.by(1)
expect(project.releases.last.name).to eq('New release')
expect(project.releases.last.tag).to eq('v0.1')
expect(project.releases.last.description).to eq('Super nice release')
release = project.releases.last
aggregate_failures do
expect(release.name).to eq('New release')
expect(release.tag).to eq('v0.1')
expect(release.description).to eq('Super nice release')
expect(release.links.last.name).to eq('An example runbook link')
expect(release.links.last.url).to eq('https://example.com/runbook')
expect(release.links.last.link_type).to eq('runbook')
expect(release.links.last.filepath).to eq('/permanent/path/to/runbook')
end
end
it 'creates a new release without description' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment