internal_group_access_spec.rb 2.76 KB
Newer Older
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
1 2
require 'spec_helper'

3
describe "Group with internal project access" do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
4 5 6
  describe "Group" do
    let(:group) { create(:group) }

7
    let(:owner)   { create(:owner) }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
8 9 10
    let(:master)   { create(:user) }
    let(:reporter) { create(:user) }
    let(:guest)    { create(:user) }
11
    let(:nonmember)  { create(:user) }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
12 13

    before do
14
      group.add_user(owner, Gitlab::Access::OWNER)
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
15 16 17
      group.add_user(master, Gitlab::Access::MASTER)
      group.add_user(reporter, Gitlab::Access::REPORTER)
      group.add_user(guest, Gitlab::Access::GUEST)
18 19 20 21 22 23 24
      
      create(:project, group: group, visibility_level: Gitlab::VisibilityLevel::INTERNAL)
    end
    
    describe "Group should have accessible projects for users" do
      it { group.has_projects_accessible_to?(nil).should be_false }
      it { group.has_projects_accessible_to?(nonmember).should be_true }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
25 26 27 28 29
    end

    describe "GET /groups/:path" do
      subject { group_path(group) }

30
      it { should be_allowed_for owner }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
31 32 33 34
      it { should be_allowed_for master }
      it { should be_allowed_for reporter }
      it { should be_allowed_for :admin }
      it { should be_allowed_for guest }
35
      it { should be_allowed_for :user }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
36 37 38 39 40 41
      it { should be_denied_for :visitor }
    end

    describe "GET /groups/:path/issues" do
      subject { issues_group_path(group) }

42
      it { should be_allowed_for owner }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
43 44 45 46
      it { should be_allowed_for master }
      it { should be_allowed_for reporter }
      it { should be_allowed_for :admin }
      it { should be_allowed_for guest }
47
      it { should be_allowed_for :user }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
48 49 50 51 52 53
      it { should be_denied_for :visitor }
    end

    describe "GET /groups/:path/merge_requests" do
      subject { merge_requests_group_path(group) }

54
      it { should be_allowed_for owner }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
55 56 57 58
      it { should be_allowed_for master }
      it { should be_allowed_for reporter }
      it { should be_allowed_for :admin }
      it { should be_allowed_for guest }
59
      it { should be_allowed_for :user }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
60 61 62 63 64 65
      it { should be_denied_for :visitor }
    end

    describe "GET /groups/:path/members" do
      subject { members_group_path(group) }

66
      it { should be_allowed_for owner }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
67 68 69 70
      it { should be_allowed_for master }
      it { should be_allowed_for reporter }
      it { should be_allowed_for :admin }
      it { should be_allowed_for guest }
71
      it { should be_allowed_for :user }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
72 73 74 75 76 77
      it { should be_denied_for :visitor }
    end

    describe "GET /groups/:path/edit" do
      subject { edit_group_path(group) }

78
      it { should be_allowed_for owner }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
79 80 81 82 83 84 85 86 87
      it { should be_denied_for master }
      it { should be_denied_for reporter }
      it { should be_allowed_for :admin }
      it { should be_denied_for guest }
      it { should be_denied_for :user }
      it { should be_denied_for :visitor }
    end
  end
end