private_access_spec.rb 3.6 KB
Newer Older
Felipe Artur's avatar
Felipe Artur committed
1 2
require 'rails_helper'

3
describe 'Private Group access' do
Felipe Artur's avatar
Felipe Artur committed
4 5
  include AccessMatchers

6
  let(:group)   { create(:group, :private) }
Douwe Maan's avatar
Douwe Maan committed
7
  let(:project) { create(:project, :private, group: group) }
8 9 10 11
  let(:project_guest) do
    create(:user) do |user|
      project.add_guest(user)
    end
Felipe Artur's avatar
Felipe Artur committed
12 13
  end

Douwe Maan's avatar
Douwe Maan committed
14 15 16 17
  describe "Group should be private" do
    describe '#private?' do
      subject { group.private? }
      it { is_expected.to be_truthy }
Felipe Artur's avatar
Felipe Artur committed
18
    end
Douwe Maan's avatar
Douwe Maan committed
19
  end
Felipe Artur's avatar
Felipe Artur committed
20

Douwe Maan's avatar
Douwe Maan committed
21 22 23
  describe 'GET /groups/:path' do
    subject { group_path(group) }

24 25 26 27 28 29 30 31 32 33
    it { is_expected.to be_allowed_for(:admin) }
    it { is_expected.to be_allowed_for(:owner).of(group) }
    it { is_expected.to be_allowed_for(:master).of(group) }
    it { is_expected.to be_allowed_for(:developer).of(group) }
    it { is_expected.to be_allowed_for(:reporter).of(group) }
    it { is_expected.to be_allowed_for(:guest).of(group) }
    it { is_expected.to be_allowed_for(project_guest) }
    it { is_expected.to be_denied_for(:user) }
    it { is_expected.to be_denied_for(:external) }
    it { is_expected.to be_denied_for(:visitor) }
Felipe Artur's avatar
Felipe Artur committed
34 35
  end

Douwe Maan's avatar
Douwe Maan committed
36 37 38
  describe 'GET /groups/:path/issues' do
    subject { issues_group_path(group) }

39 40 41 42 43 44 45 46 47 48
    it { is_expected.to be_allowed_for(:admin) }
    it { is_expected.to be_allowed_for(:owner).of(group) }
    it { is_expected.to be_allowed_for(:master).of(group) }
    it { is_expected.to be_allowed_for(:developer).of(group) }
    it { is_expected.to be_allowed_for(:reporter).of(group) }
    it { is_expected.to be_allowed_for(:guest).of(group) }
    it { is_expected.to be_allowed_for(project_guest) }
    it { is_expected.to be_denied_for(:user) }
    it { is_expected.to be_denied_for(:external) }
    it { is_expected.to be_denied_for(:visitor) }
Douwe Maan's avatar
Douwe Maan committed
49
  end
Felipe Artur's avatar
Felipe Artur committed
50

Douwe Maan's avatar
Douwe Maan committed
51 52 53
  describe 'GET /groups/:path/merge_requests' do
    subject { merge_requests_group_path(group) }

54 55 56 57 58 59 60 61 62 63
    it { is_expected.to be_allowed_for(:admin) }
    it { is_expected.to be_allowed_for(:owner).of(group) }
    it { is_expected.to be_allowed_for(:master).of(group) }
    it { is_expected.to be_allowed_for(:developer).of(group) }
    it { is_expected.to be_allowed_for(:reporter).of(group) }
    it { is_expected.to be_allowed_for(:guest).of(group) }
    it { is_expected.to be_allowed_for(project_guest) }
    it { is_expected.to be_denied_for(:user) }
    it { is_expected.to be_denied_for(:external) }
    it { is_expected.to be_denied_for(:visitor) }
Felipe Artur's avatar
Felipe Artur committed
64 65 66
  end

  describe 'GET /groups/:path/group_members' do
Douwe Maan's avatar
Douwe Maan committed
67 68
    subject { group_group_members_path(group) }

69 70 71 72 73 74 75 76 77 78
    it { is_expected.to be_allowed_for(:admin) }
    it { is_expected.to be_allowed_for(:owner).of(group) }
    it { is_expected.to be_allowed_for(:master).of(group) }
    it { is_expected.to be_allowed_for(:developer).of(group) }
    it { is_expected.to be_allowed_for(:reporter).of(group) }
    it { is_expected.to be_allowed_for(:guest).of(group) }
    it { is_expected.to be_allowed_for(project_guest) }
    it { is_expected.to be_denied_for(:user) }
    it { is_expected.to be_denied_for(:external) }
    it { is_expected.to be_denied_for(:visitor) }
Felipe Artur's avatar
Felipe Artur committed
79 80 81
  end

  describe 'GET /groups/:path/edit' do
Douwe Maan's avatar
Douwe Maan committed
82 83
    subject { edit_group_path(group) }

84 85 86 87 88 89 90 91 92 93
    it { is_expected.to be_allowed_for(:admin) }
    it { is_expected.to be_allowed_for(:owner).of(group) }
    it { is_expected.to be_denied_for(:master).of(group) }
    it { is_expected.to be_denied_for(:developer).of(group) }
    it { is_expected.to be_denied_for(:reporter).of(group) }
    it { is_expected.to be_denied_for(:guest).of(group) }
    it { is_expected.to be_denied_for(project_guest) }
    it { is_expected.to be_denied_for(:user) }
    it { is_expected.to be_denied_for(:visitor) }
    it { is_expected.to be_denied_for(:external) }
Felipe Artur's avatar
Felipe Artur committed
94 95
  end
end