diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/lib/gitlab/git_access_design_spec.rb | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/lib/gitlab/git_access_design_spec.rb')
-rw-r--r-- | spec/lib/gitlab/git_access_design_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/lib/gitlab/git_access_design_spec.rb b/spec/lib/gitlab/git_access_design_spec.rb new file mode 100644 index 00000000000..d816608f7e5 --- /dev/null +++ b/spec/lib/gitlab/git_access_design_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true +require 'spec_helper' + +describe Gitlab::GitAccessDesign do + include DesignManagementTestHelpers + + let_it_be(:project) { create(:project) } + let_it_be(:user) { project.owner } + let(:protocol) { 'web' } + let(:actor) { user } + + subject(:access) do + described_class.new(actor, project, protocol, authentication_abilities: [:read_project, :download_code, :push_code]) + end + + describe '#check' do + subject { access.check('git-receive-pack', ::Gitlab::GitAccess::ANY) } + + before do + enable_design_management + end + + context 'when the user is allowed to manage designs' do + it do + is_expected.to be_a(::Gitlab::GitAccessResult::Success) + end + end + + context 'when the user is not allowed to manage designs' do + let_it_be(:user) { create(:user) } + + it 'raises an error' do + expect { subject }.to raise_error(::Gitlab::GitAccess::ForbiddenError) + end + end + + context 'when the protocol is not web' do + let(:protocol) { 'https' } + + it 'raises an error' do + expect { subject }.to raise_error(::Gitlab::GitAccess::ForbiddenError) + end + end + end +end |