diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-15 21:09:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-15 21:09:05 +0300 |
commit | a0213db466c75403a5a79f95af8a0a5cff13014c (patch) | |
tree | 6118144407f99f1121c34e934cf0d96c991d578e /spec/requests/api | |
parent | f5c3f32975addd56fe8659f1c346d0e56f0b23d9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api')
-rw-r--r-- | spec/requests/api/ci/pipelines_spec.rb | 5 | ||||
-rw-r--r-- | spec/requests/api/generic_packages_spec.rb | 10 | ||||
-rw-r--r-- | spec/requests/api/graphql/mutations/release_asset_links/update_spec.rb | 67 | ||||
-rw-r--r-- | spec/requests/api/jobs_spec.rb | 1 |
4 files changed, 77 insertions, 6 deletions
diff --git a/spec/requests/api/ci/pipelines_spec.rb b/spec/requests/api/ci/pipelines_spec.rb index a9afbd8bd72..d0c2b383013 100644 --- a/spec/requests/api/ci/pipelines_spec.rb +++ b/spec/requests/api/ci/pipelines_spec.rb @@ -34,7 +34,7 @@ RSpec.describe API::Ci::Pipelines do expect(json_response.first['sha']).to match(/\A\h{40}\z/) expect(json_response.first['id']).to eq pipeline.id expect(json_response.first['web_url']).to be_present - expect(json_response.first.keys).to contain_exactly(*%w[id sha ref status web_url created_at updated_at]) + expect(json_response.first.keys).to contain_exactly(*%w[id project_id sha ref status web_url created_at updated_at]) end context 'when parameter is passed' do @@ -350,6 +350,7 @@ RSpec.describe API::Ci::Pipelines do expect(json_job['pipeline']).not_to be_empty expect(json_job['pipeline']['id']).to eq job.pipeline.id + expect(json_job['pipeline']['project_id']).to eq job.pipeline.project_id expect(json_job['pipeline']['ref']).to eq job.pipeline.ref expect(json_job['pipeline']['sha']).to eq job.pipeline.sha expect(json_job['pipeline']['status']).to eq job.pipeline.status @@ -512,6 +513,7 @@ RSpec.describe API::Ci::Pipelines do expect(json_bridge['pipeline']).not_to be_empty expect(json_bridge['pipeline']['id']).to eq bridge.pipeline.id + expect(json_bridge['pipeline']['project_id']).to eq bridge.pipeline.project_id expect(json_bridge['pipeline']['ref']).to eq bridge.pipeline.ref expect(json_bridge['pipeline']['sha']).to eq bridge.pipeline.sha expect(json_bridge['pipeline']['status']).to eq bridge.pipeline.status @@ -522,6 +524,7 @@ RSpec.describe API::Ci::Pipelines do expect(json_bridge['downstream_pipeline']).not_to be_empty expect(json_bridge['downstream_pipeline']['id']).to eq downstream_pipeline.id + expect(json_bridge['downstream_pipeline']['project_id']).to eq downstream_pipeline.project_id expect(json_bridge['downstream_pipeline']['ref']).to eq downstream_pipeline.ref expect(json_bridge['downstream_pipeline']['sha']).to eq downstream_pipeline.sha expect(json_bridge['downstream_pipeline']['status']).to eq downstream_pipeline.status diff --git a/spec/requests/api/generic_packages_spec.rb b/spec/requests/api/generic_packages_spec.rb index a47be1ead9c..16d56b6cfbe 100644 --- a/spec/requests/api/generic_packages_spec.rb +++ b/spec/requests/api/generic_packages_spec.rb @@ -444,17 +444,17 @@ RSpec.describe API::GenericPackages do 'PUBLIC' | :guest | true | :user_basic_auth | :success 'PUBLIC' | :developer | true | :invalid_personal_access_token | :unauthorized 'PUBLIC' | :guest | true | :invalid_personal_access_token | :unauthorized - 'PUBLIC' | :developer | true | :invalid_user_basic_auth | :unauthorized - 'PUBLIC' | :guest | true | :invalid_user_basic_auth | :unauthorized + 'PUBLIC' | :developer | true | :invalid_user_basic_auth | :success + 'PUBLIC' | :guest | true | :invalid_user_basic_auth | :success 'PUBLIC' | :developer | false | :personal_access_token | :success 'PUBLIC' | :guest | false | :personal_access_token | :success 'PUBLIC' | :developer | false | :user_basic_auth | :success 'PUBLIC' | :guest | false | :user_basic_auth | :success 'PUBLIC' | :developer | false | :invalid_personal_access_token | :unauthorized 'PUBLIC' | :guest | false | :invalid_personal_access_token | :unauthorized - 'PUBLIC' | :developer | false | :invalid_user_basic_auth | :unauthorized - 'PUBLIC' | :guest | false | :invalid_user_basic_auth | :unauthorized - 'PUBLIC' | :anonymous | false | :none | :unauthorized + 'PUBLIC' | :developer | false | :invalid_user_basic_auth | :success + 'PUBLIC' | :guest | false | :invalid_user_basic_auth | :success + 'PUBLIC' | :anonymous | false | :none | :success 'PRIVATE' | :developer | true | :personal_access_token | :success 'PRIVATE' | :guest | true | :personal_access_token | :forbidden 'PRIVATE' | :developer | true | :user_basic_auth | :success diff --git a/spec/requests/api/graphql/mutations/release_asset_links/update_spec.rb b/spec/requests/api/graphql/mutations/release_asset_links/update_spec.rb new file mode 100644 index 00000000000..92b558d4be3 --- /dev/null +++ b/spec/requests/api/graphql/mutations/release_asset_links/update_spec.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Updating an existing release asset link' 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 + external + } + 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]), + external: true + }.with_indifferent_access + + expect(mutation_response[:link]).to include(expected_response) + expect(mutation_response[:errors]).to eq([]) + end +end diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb index a21482c2874..fe00b654d3b 100644 --- a/spec/requests/api/jobs_spec.rb +++ b/spec/requests/api/jobs_spec.rb @@ -44,6 +44,7 @@ RSpec.describe API::Jobs do it 'returns common pipeline data' do expect(json_response['pipeline']).not_to be_empty expect(json_response['pipeline']['id']).to eq jobx.pipeline.id + expect(json_response['pipeline']['project_id']).to eq jobx.pipeline.project_id expect(json_response['pipeline']['ref']).to eq jobx.pipeline.ref expect(json_response['pipeline']['sha']).to eq jobx.pipeline.sha expect(json_response['pipeline']['status']).to eq jobx.pipeline.status |