internal_access_spec.rb 3.63 KB
Newer Older
Felipe Artur's avatar
Felipe Artur committed
1 2
require 'rails_helper'

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

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

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

15 16 17
  let(:project_guest) { create(:user) }

  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)
23 24

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

27 28 29 30
  describe "Group should be internal" do
    describe '#internal?' do
      subject { group.internal? }
      it { is_expected.to be_truthy }
Felipe Artur's avatar
Felipe Artur committed
31
    end
32
  end
Felipe Artur's avatar
Felipe Artur committed
33

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_allowed_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

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_allowed_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

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_allowed_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
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_allowed_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
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