Commit 948bd107 authored by David O'Regan's avatar David O'Regan

Merge branch 'afontaine/persist-permanent-asset-links' into 'master'

Persist Direct Asset Path on Release Updates

See merge request gitlab-org/gitlab!64719
parents 0b27fd04 6c29da3e
......@@ -9,6 +9,7 @@ fragment ReleaseForEditing on Release {
name
url
linkType
directAssetPath
}
}
}
......
......@@ -165,6 +165,7 @@ const createReleaseLink = async ({ state, link }) => {
name: link.name,
url: link.url,
linkType: link.linkType.toUpperCase(),
directAssetPath: link.directAssetPath,
},
},
});
......
......@@ -20,6 +20,8 @@ module Types
field :direct_asset_url, GraphQL::STRING_TYPE, null: true,
description: 'Direct asset URL of the link.'
field :direct_asset_path, GraphQL::STRING_TYPE, null: true, method: :filepath,
description: 'Relative path for the direct asset link.'
def direct_asset_url
return object.url unless object.filepath
......
......@@ -12259,6 +12259,7 @@ Represents an asset link associated with a release.
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="releaseassetlinkdirectassetpath"></a>`directAssetPath` | [`String`](#string) | Relative path for the direct asset link. |
| <a id="releaseassetlinkdirectasseturl"></a>`directAssetUrl` | [`String`](#string) | Direct asset URL of the link. |
| <a id="releaseassetlinkexternal"></a>`external` | [`Boolean`](#boolean) | Indicates the link points to an external resource. |
| <a id="releaseassetlinkid"></a>`id` | [`ID!`](#id) | ID of the link. |
......
......@@ -4,9 +4,11 @@ require 'spec_helper'
RSpec.describe 'User edits Release', :js do
let_it_be(:project) { create(:project, :repository) }
let_it_be(:release) { create(:release, :with_milestones, milestones_count: 1, project: project, name: 'The first release' ) }
let_it_be(:user) { create(:user) }
let(:release) { create(:release, :with_milestones, milestones_count: 1, project: project, name: 'The first release' ) }
let(:release_link) { create(:release_link, release: release) }
before do
project.add_developer(user)
......@@ -68,6 +70,14 @@ RSpec.describe 'User edits Release', :js do
expect(release.description).to eq('Updated Release notes')
end
it 'does not affect the asset link' do
fill_out_form_and_click 'Save changes'
expected_filepath = release_link.filepath
release_link.reload
expect(release_link.filepath).to eq(expected_filepath)
end
it 'redirects to the previous page when "Cancel" is clicked when the url includes a back_url query parameter' do
back_path = project_releases_path(project, params: { page: 2 })
visit edit_project_release_path(project, release, params: { back_url: back_path })
......
......@@ -212,24 +212,28 @@ Object {
"count": undefined,
"links": Array [
Object {
"directAssetPath": "/binaries/awesome-app-3",
"id": "gid://gitlab/Releases::Link/13",
"linkType": "image",
"name": "Image",
"url": "https://example.com/image",
},
Object {
"directAssetPath": "/binaries/awesome-app-2",
"id": "gid://gitlab/Releases::Link/12",
"linkType": "package",
"name": "Package",
"url": "https://example.com/package",
},
Object {
"directAssetPath": "/binaries/awesome-app-1",
"id": "gid://gitlab/Releases::Link/11",
"linkType": "runbook",
"name": "Runbook",
"url": "http://localhost/releases-namespace/releases-project/runbook",
},
Object {
"directAssetPath": "/binaries/linux-amd64",
"id": "gid://gitlab/Releases::Link/10",
"linkType": "other",
"name": "linux-amd64 binaries",
......
......@@ -7,7 +7,7 @@ RSpec.describe GitlabSchema.types['ReleaseAssetLink'] do
it 'has the expected fields' do
expected_fields = %w[
id name url external link_type direct_asset_url
id name url external link_type direct_asset_url direct_asset_path
]
expect(described_class).to include_graphql_fields(*expected_fields)
......
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