public_access_spec.rb 3.68 KB
Newer Older
Felipe Artur's avatar
Felipe Artur committed
1 2
require 'rails_helper'

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

6
  let(:group)   { create(:group, :public) }
7
  let(:project) { create(:empty_project, :public, 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

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

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_allowed_for(:user) }
    it { is_expected.to be_allowed_for(:external) }
    it { is_expected.to be_allowed_for(:visitor) }
Felipe Artur's avatar
Felipe Artur committed
34 35
  end

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_allowed_for(:user) }
    it { is_expected.to be_allowed_for(:external) }
    it { is_expected.to be_allowed_for(:visitor) }
49
  end
Felipe Artur's avatar
Felipe Artur committed
50

51
  describe 'GET /groups/:path/merge_requests' do
52
    let(:project) { create(:project, :public, :repository, group: group) }
53 54
    subject { merge_requests_group_path(group) }

55 56 57 58 59 60 61 62 63 64
    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_allowed_for(:user) }
    it { is_expected.to be_allowed_for(:external) }
    it { is_expected.to be_allowed_for(:visitor) }
Felipe Artur's avatar
Felipe Artur committed
65 66 67
  end

  describe 'GET /groups/:path/group_members' do
68 69
    subject { group_group_members_path(group) }

70 71 72 73 74 75 76 77 78 79
    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_allowed_for(:user) }
    it { is_expected.to be_allowed_for(:external) }
    it { is_expected.to be_allowed_for(:visitor) }
Felipe Artur's avatar
Felipe Artur committed
80 81 82
  end

  describe 'GET /groups/:path/edit' do
83 84
    subject { edit_group_path(group) }

85 86 87 88 89 90 91 92 93 94
    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
95 96
  end
end