|
|
|
@ -35,6 +35,7 @@ describe Capabilities::Scopes::Default, type: :model do |
|
|
|
|
let(:permissions) { %i[] } |
|
|
|
|
let(:global_permissions) { %i[] } |
|
|
|
|
let(:non_member_permissions) { %i[] } |
|
|
|
|
let(:anonymous_permissions) { %i[] } |
|
|
|
|
let(:project_public) { false } |
|
|
|
|
let(:project_active) { true } |
|
|
|
|
let!(:project) { create(:project, public: project_public, active: project_active) } |
|
|
|
@ -63,6 +64,10 @@ describe Capabilities::Scopes::Default, type: :model do |
|
|
|
|
create(:non_member, |
|
|
|
|
permissions: non_member_permissions) |
|
|
|
|
end |
|
|
|
|
let(:anonymous_role) do |
|
|
|
|
create(:anonymous_role, |
|
|
|
|
permissions: anonymous_permissions) |
|
|
|
|
end |
|
|
|
|
let(:own_role) { create(:role, permissions: []) } |
|
|
|
|
let(:own_member) do |
|
|
|
|
create(:member, |
|
|
|
@ -180,6 +185,42 @@ describe Capabilities::Scopes::Default, type: :model do |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'with the anonymous role having the action permission in a public project' do |
|
|
|
|
let(:anonymous_permissions) { %i[view_members] } |
|
|
|
|
let(:project_public) { true } |
|
|
|
|
let(:members) { [anonymous_role] } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'is empty' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'with the anonymous user with an action permission' do |
|
|
|
|
let(:anonymous_permissions) { %i[view_members] } |
|
|
|
|
let!(:user) { create(:anonymous) } |
|
|
|
|
let(:members) { [anonymous_role] } |
|
|
|
|
|
|
|
|
|
context 'with the project being private' do |
|
|
|
|
it_behaves_like 'is empty' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'with the anonymous role not having the permission' do |
|
|
|
|
let(:anonymous_permissions) { %i[] } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'is empty' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'with the project being public' do |
|
|
|
|
let(:project_public) { true } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'consists of contract actions' do |
|
|
|
|
let(:expected) do |
|
|
|
|
[ |
|
|
|
|
['memberships/read', user.id, project.id] |
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'with a member without a permission and with the non member having a permission' do |
|
|
|
|
let(:non_member_permissions) { %i[view_members] } |
|
|
|
|
let(:members) { [member, non_member_role] } |
|
|
|
|