Allow teachers to access internal users and manage them in their study groups

This commit is contained in:
Sebastian Serth
2022-09-22 17:55:10 +02:00
committed by Sebastian Serth
parent e3018c1847
commit 0e7c38657f
11 changed files with 45 additions and 22 deletions

View File

@ -5,7 +5,7 @@ require 'rails_helper'
describe InternalUserPolicy do
subject(:policy) { described_class }
%i[create? edit? index? new? show? update?].each do |action|
%i[create? edit? new? show? update?].each do |action|
permissions(action) do
it 'grants access to admins only' do
expect(policy).to permit(build(:admin), InternalUser.new)
@ -16,6 +16,15 @@ describe InternalUserPolicy do
end
end
permissions :index? do
it 'grants access to admins and teachers only' do
expect(policy).not_to permit(build(:external_user), InternalUser.new)
%i[admin teacher].each do |factory_name|
expect(policy).to permit(create(factory_name), InternalUser.new)
end
end
end
permissions :destroy? do
context 'with an admin user' do
it 'grants access to no one' do