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