diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-01 15:13:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-01 15:13:32 +0300 |
commit | 6c7d90ede4d2890b2ca740239cd9a5338f12ba34 (patch) | |
tree | 59a0fde813364a626fe201dc58316dee001f96e1 /spec/graphql | |
parent | 3cb9e9a5070184e59cb6ff33a4ce381ed14a6fe5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
-rw-r--r-- | spec/graphql/mutations/dependency_proxy/group_settings/update_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/graphql/mutations/dependency_proxy/group_settings/update_spec.rb b/spec/graphql/mutations/dependency_proxy/group_settings/update_spec.rb new file mode 100644 index 00000000000..35d3224d5ba --- /dev/null +++ b/spec/graphql/mutations/dependency_proxy/group_settings/update_spec.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Mutations::DependencyProxy::GroupSettings::Update do + using RSpec::Parameterized::TableSyntax + + let_it_be_with_reload(:group) { create(:group) } + let_it_be_with_reload(:group_settings) { create(:dependency_proxy_group_setting, group: group) } + let_it_be(:user) { create(:user) } + + let(:params) { { group_path: group.full_path, enabled: false } } + + specify { expect(described_class).to require_graphql_authorizations(:admin_dependency_proxy) } + + describe '#resolve' do + subject { described_class.new(object: group, context: { current_user: user }, field: nil).resolve(**params) } + + shared_examples 'updating the dependency proxy group settings' do + it_behaves_like 'updating the dependency proxy group settings attributes', + from: { enabled: true }, + to: { enabled: false } + + it 'returns the dependency proxy settings no errors' do + expect(subject).to eq( + dependency_proxy_setting: group_settings, + errors: [] + ) + end + end + + shared_examples 'denying access to dependency proxy group settings' do + it 'raises Gitlab::Graphql::Errors::ResourceNotAvailable' do + expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable) + end + end + + where(:user_role, :shared_examples_name) do + :maintainer | 'updating the dependency proxy group settings' + :developer | 'updating the dependency proxy group settings' + :reporter | 'denying access to dependency proxy group settings' + :guest | 'denying access to dependency proxy group settings' + :anonymous | 'denying access to dependency proxy group settings' + end + + with_them do + before do + stub_config(dependency_proxy: { enabled: true }) + group.send("add_#{user_role}", user) unless user_role == :anonymous + end + + it_behaves_like params[:shared_examples_name] + end + end +end |