Commit a089f4f4 authored by http://jneen.net/'s avatar http://jneen.net/

convert ee policy specs

parent 268157f9
...@@ -18,19 +18,19 @@ describe GroupPolicy, models: true do ...@@ -18,19 +18,19 @@ describe GroupPolicy, models: true do
group.add_owner(owner) group.add_owner(owner)
end end
subject { described_class.abilities(current_user, group).to_set } subject { described_class.new(current_user, group) }
context 'when LDAP sync is not enabled' do context 'when LDAP sync is not enabled' do
context 'owner' do context 'owner' do
let(:current_user) { owner } let(:current_user) { owner }
it { is_expected.not_to include(:override_group_member) } it { is_expected.to be_disallowed(:override_group_member) }
end end
context 'admin' do context 'admin' do
let(:current_user) { admin } let(:current_user) { admin }
it { is_expected.not_to include(:override_group_member) } it { is_expected.to be_disallowed(:override_group_member) }
end end
end end
...@@ -42,43 +42,43 @@ describe GroupPolicy, models: true do ...@@ -42,43 +42,43 @@ describe GroupPolicy, models: true do
context 'with no user' do context 'with no user' do
let(:current_user) { nil } let(:current_user) { nil }
it { is_expected.not_to include(:override_group_member) } it { is_expected.to be_disallowed(:override_group_member) }
end end
context 'guests' do context 'guests' do
let(:current_user) { guest } let(:current_user) { guest }
it { is_expected.not_to include(:override_group_member) } it { is_expected.to be_disallowed(:override_group_member) }
end end
context 'reporter' do context 'reporter' do
let(:current_user) { reporter } let(:current_user) { reporter }
it { is_expected.not_to include(:override_group_member) } it { is_expected.to be_disallowed(:override_group_member) }
end end
context 'developer' do context 'developer' do
let(:current_user) { developer } let(:current_user) { developer }
it { is_expected.not_to include(:override_group_member) } it { is_expected.to be_disallowed(:override_group_member) }
end end
context 'master' do context 'master' do
let(:current_user) { master } let(:current_user) { master }
it { is_expected.not_to include(:override_group_member) } it { is_expected.to be_disallowed(:override_group_member) }
end end
context 'owner' do context 'owner' do
let(:current_user) { owner } let(:current_user) { owner }
it { is_expected.to include(:override_group_member) } it { is_expected.to be_allowed(:override_group_member) }
end end
context 'admin' do context 'admin' do
let(:current_user) { admin } let(:current_user) { admin }
it { is_expected.to include(:override_group_member) } it { is_expected.to be_allowed(:override_group_member) }
end end
end end
end end
...@@ -211,10 +211,9 @@ describe GroupPolicy, models: true do ...@@ -211,10 +211,9 @@ describe GroupPolicy, models: true do
let(:current_user) { auditor } let(:current_user) { auditor }
it do it do
is_expected.to include(:read_group) is_expected.to be_allowed(:read_group)
is_expected.to all(start_with("read")) is_expected.to be_disallowed(*master_permissions)
is_expected.not_to include(*master_permissions) is_expected.to be_disallowed(*owner_permissions)
is_expected.not_to include(*owner_permissions)
end end
end end
end end
......
...@@ -11,24 +11,24 @@ describe NamespacePolicy, models: true do ...@@ -11,24 +11,24 @@ describe NamespacePolicy, models: true do
let(:admin_permissions) { owner_permissions } let(:admin_permissions) { owner_permissions }
subject { described_class.abilities(current_user, namespace).to_set } subject { described_class.new(current_user, namespace) }
context 'with no user' do context 'with no user' do
let(:current_user) { nil } let(:current_user) { nil }
it { is_expected.to be_empty } it { is_expected.to be_banned }
end end
context 'regular user' do context 'regular user' do
let(:current_user) { user } let(:current_user) { user }
it { is_expected.to be_empty } it { is_expected.to be_disallowed(*owner_permissions) }
end end
context 'owner' do context 'owner' do
let(:current_user) { owner } let(:current_user) { owner }
it { is_expected.to include(*owner_permissions) } it { is_expected.to be_allowed(*owner_permissions) }
end end
context 'auditor' do context 'auditor' do
...@@ -37,17 +37,17 @@ describe NamespacePolicy, models: true do ...@@ -37,17 +37,17 @@ describe NamespacePolicy, models: true do
context 'owner' do context 'owner' do
let(:namespace) { create(:namespace, owner: auditor) } let(:namespace) { create(:namespace, owner: auditor) }
it { is_expected.to include(*owner_permissions) } it { is_expected.to be_allowed(*owner_permissions) }
end end
context 'non-owner' do context 'non-owner' do
it { is_expected.to be_empty } it { is_expected.to be_disallowed(*owner_permissions) }
end end
end end
context 'admin' do context 'admin' do
let(:current_user) { admin } let(:current_user) { admin }
it { is_expected.to include(*owner_permissions) } it { is_expected.to be_allowed(*owner_permissions) }
end end
end end
...@@ -243,10 +243,10 @@ describe ProjectPolicy, models: true do ...@@ -243,10 +243,10 @@ describe ProjectPolicy, models: true do
let(:current_user) { auditor } let(:current_user) { auditor }
it do it do
is_expected.not_to include(*developer_permissions) is_expected.to be_disallowed(*developer_permissions)
is_expected.not_to include(*master_permissions) is_expected.to be_disallowed(*master_permissions)
is_expected.not_to include(*owner_permissions) is_expected.to be_disallowed(*owner_permissions)
is_expected.to include(*auditor_permissions) is_expected.to be_allowed(*auditor_permissions)
end end
end end
end end
......
...@@ -101,8 +101,8 @@ describe ProjectSnippetPolicy, models: true do ...@@ -101,8 +101,8 @@ describe ProjectSnippetPolicy, models: true do
subject { abilities(current_user, :private) } subject { abilities(current_user, :private) }
it do it do
is_expected.not_to include(:read_project_snippet) is_expected.to be_disallowed(:read_project_snippet)
is_expected.not_to include(*author_permissions) is_expected.to be_disallowed(*author_permissions)
end end
end end
end end
...@@ -168,8 +168,8 @@ describe ProjectSnippetPolicy, models: true do ...@@ -168,8 +168,8 @@ describe ProjectSnippetPolicy, models: true do
subject { abilities(current_user, :private) } subject { abilities(current_user, :private) }
it do it do
is_expected.to include(:read_project_snippet) is_expected.to be_allowed(:read_project_snippet)
is_expected.not_to include(*author_permissions) is_expected.to be_disallowed(*author_permissions)
end end
end end
......
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