1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Updating an existing release asset link', feature_category: :release_orchestration do
include GraphqlHelpers
let_it_be(:project) { create(:project, :private, :repository) }
let_it_be(:release) { create(:release, project: project) }
let_it_be(:developer) { create(:user).tap { |u| project.add_developer(u) } }
let_it_be(:release_link) do
create(:release_link,
release: release,
name: 'link name',
url: 'https://example.com/url',
filepath: '/permanent/path',
link_type: 'package')
end
let(:current_user) { developer }
let(:mutation_name) { :release_asset_link_update }
let(:mutation_arguments) do
{
id: release_link.to_global_id.to_s,
name: 'updated name',
url: 'https://example.com/updated',
directAssetPath: '/updated/path',
linkType: 'IMAGE'
}
end
let(:mutation) do
graphql_mutation(mutation_name, mutation_arguments, <<~FIELDS)
link {
id
name
url
linkType
directAssetUrl
}
errors
FIELDS
end
let(:update_link) { post_graphql_mutation(mutation, current_user: current_user) }
let(:mutation_response) { graphql_mutation_response(mutation_name)&.with_indifferent_access }
it 'updates and existing release asset link and returns the updated link', :aggregate_failures do
update_link
expected_response = {
id: mutation_arguments[:id],
name: mutation_arguments[:name],
url: mutation_arguments[:url],
linkType: mutation_arguments[:linkType],
directAssetUrl: end_with(mutation_arguments[:directAssetPath])
}.with_indifferent_access
expect(mutation_response[:link]).to include(expected_response)
expect(mutation_response[:errors]).to eq([])
end
end
|