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

Douwe Maan's avatar
Douwe Maan committed
3
describe 'Private Group access', feature: true do
Felipe Artur's avatar
Felipe Artur committed
4 5
  include AccessMatchers

Douwe Maan's avatar
Douwe Maan committed
6 7
  let(:group) { create(:group, :private) }
  let(:project) { create(:project, :private, group: group) }
Felipe Artur's avatar
Felipe Artur committed
8

Douwe Maan's avatar
Douwe Maan committed
9 10 11 12 13
  let(:owner)     { create(:user) }
  let(:master)    { create(:user) }
  let(:developer) { create(:user) }
  let(:reporter)  { create(:user) }
  let(:guest)     { create(:user) }
Felipe Artur's avatar
Felipe Artur committed
14

Douwe Maan's avatar
Douwe Maan committed
15
  let(:project_guest) { create(:user) }
Felipe Artur's avatar
Felipe Artur committed
16

Douwe Maan's avatar
Douwe Maan committed
17
  before do
Douwe Maan's avatar
Douwe Maan committed
18 19 20 21 22
    group.add_owner(owner)
    group.add_master(master)
    group.add_developer(developer)
    group.add_reporter(reporter)
    group.add_guest(guest)
Douwe Maan's avatar
Douwe Maan committed
23 24

    project.team << [project_guest, :guest]
Felipe Artur's avatar
Felipe Artur committed
25 26
  end

Douwe Maan's avatar
Douwe Maan committed
27 28 29 30
  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
31
    end
Douwe Maan's avatar
Douwe Maan committed
32
  end
Felipe Artur's avatar
Felipe Artur committed
33

Douwe Maan's avatar
Douwe Maan committed
34 35 36 37 38 39 40 41 42 43 44 45 46
  describe 'GET /groups/:path' do
    subject { group_path(group) }

    it { is_expected.to be_allowed_for :admin }
    it { is_expected.to be_allowed_for owner }
    it { is_expected.to be_allowed_for master }
    it { is_expected.to be_allowed_for developer }
    it { is_expected.to be_allowed_for reporter }
    it { is_expected.to be_allowed_for guest }
    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
47 48
  end

Douwe Maan's avatar
Douwe Maan committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62
  describe 'GET /groups/:path/issues' do
    subject { issues_group_path(group) }

    it { is_expected.to be_allowed_for :admin }
    it { is_expected.to be_allowed_for owner }
    it { is_expected.to be_allowed_for master }
    it { is_expected.to be_allowed_for developer }
    it { is_expected.to be_allowed_for reporter }
    it { is_expected.to be_allowed_for guest }
    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 }
  end
Felipe Artur's avatar
Felipe Artur committed
63

Douwe Maan's avatar
Douwe Maan committed
64 65 66 67 68 69 70 71 72 73 74 75 76
  describe 'GET /groups/:path/merge_requests' do
    subject { merge_requests_group_path(group) }

    it { is_expected.to be_allowed_for :admin }
    it { is_expected.to be_allowed_for owner }
    it { is_expected.to be_allowed_for master }
    it { is_expected.to be_allowed_for developer }
    it { is_expected.to be_allowed_for reporter }
    it { is_expected.to be_allowed_for guest }
    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
77 78 79
  end

  describe 'GET /groups/:path/group_members' do
Douwe Maan's avatar
Douwe Maan committed
80 81 82 83 84 85 86 87 88 89 90 91
    subject { group_group_members_path(group) }

    it { is_expected.to be_allowed_for :admin }
    it { is_expected.to be_allowed_for owner }
    it { is_expected.to be_allowed_for master }
    it { is_expected.to be_allowed_for developer }
    it { is_expected.to be_allowed_for reporter }
    it { is_expected.to be_allowed_for guest }
    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
92 93 94
  end

  describe 'GET /groups/:path/edit' do
Douwe Maan's avatar
Douwe Maan committed
95 96 97 98 99 100 101 102 103 104 105 106
    subject { edit_group_path(group) }

    it { is_expected.to be_allowed_for :admin }
    it { is_expected.to be_allowed_for owner }
    it { is_expected.to be_denied_for master }
    it { is_expected.to be_denied_for developer }
    it { is_expected.to be_denied_for reporter }
    it { is_expected.to be_denied_for guest }
    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
107 108
  end
end