Commit 0074e7da authored by Tomasz Maczukin's avatar Tomasz Maczukin

Update policies unit tests

parent 609813fa
......@@ -57,6 +57,7 @@ describe GroupPolicy do
expect_disallowed(*developer_permissions)
expect_disallowed(*master_permissions)
expect_disallowed(*owner_permissions)
expect_disallowed(:read_namespace)
end
end
......@@ -64,7 +65,7 @@ describe GroupPolicy do
let(:current_user) { guest }
it do
expect_allowed(:read_group)
expect_allowed(:read_group, :read_namespace)
expect_disallowed(*reporter_permissions)
expect_disallowed(*developer_permissions)
expect_disallowed(*master_permissions)
......@@ -76,7 +77,7 @@ describe GroupPolicy do
let(:current_user) { reporter }
it do
expect_allowed(:read_group)
expect_allowed(:read_group, :read_namespace)
expect_allowed(*reporter_permissions)
expect_disallowed(*developer_permissions)
expect_disallowed(*master_permissions)
......@@ -88,7 +89,7 @@ describe GroupPolicy do
let(:current_user) { developer }
it do
expect_allowed(:read_group)
expect_allowed(:read_group, :read_namespace)
expect_allowed(*reporter_permissions)
expect_allowed(*developer_permissions)
expect_disallowed(*master_permissions)
......@@ -100,7 +101,7 @@ describe GroupPolicy do
let(:current_user) { master }
it do
expect_allowed(:read_group)
expect_allowed(:read_group, :read_namespace)
expect_allowed(*reporter_permissions)
expect_allowed(*developer_permissions)
expect_allowed(*master_permissions)
......@@ -114,7 +115,7 @@ describe GroupPolicy do
it do
allow(Group).to receive(:supports_nested_groups?).and_return(true)
expect_allowed(:read_group)
expect_allowed(:read_group, :read_namespace)
expect_allowed(*reporter_permissions)
expect_allowed(*developer_permissions)
expect_allowed(*master_permissions)
......@@ -128,7 +129,7 @@ describe GroupPolicy do
it do
allow(Group).to receive(:supports_nested_groups?).and_return(true)
expect_allowed(:read_group)
expect_allowed(:read_group, :read_namespace)
expect_allowed(*reporter_permissions)
expect_allowed(*developer_permissions)
expect_allowed(*master_permissions)
......
......@@ -7,9 +7,7 @@ describe NamespacePolicy do
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, owner: owner) }
let(:owner_permissions) { [:create_projects, :admin_namespace] }
let(:admin_permissions) { owner_permissions }
let(:owner_permissions) { [:create_projects, :admin_namespace, :read_namespace] }
subject { described_class.new(current_user, namespace) }
......@@ -29,6 +27,12 @@ describe NamespacePolicy do
let(:current_user) { owner }
it { is_expected.to be_allowed(*owner_permissions) }
context 'user who has exceeded project limit' do
let(:owner) { create(:user, projects_limit: 0) }
it { is_expected.to be_disallowed(:create_projects) }
end
end
context 'auditor' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment