Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git_access_design_spec.rb « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9fd1f2dcb0c610e94d86dd2cbd069d97814bce52 (plain)
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
# frozen_string_literal: true
require 'spec_helper'

RSpec.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