Hide score button if exercise has no tests

We check for all teacher-defined assessments (linter and unit tests) to determine whether scoring should be possible
This commit is contained in:
Janis4411
2022-08-08 10:37:29 +02:00
committed by Sebastian Serth
parent ba5918b4ca
commit e0c2c7b806
8 changed files with 97 additions and 8 deletions

View File

@ -112,7 +112,7 @@ describe ExercisePolicy do
end
end
%i[implement? submit?].each do |action|
%i[implement?].each do |action|
permissions(action) do
it 'grants access to anyone' do
%i[admin external_user teacher].each do |factory_name|
@ -122,6 +122,28 @@ describe ExercisePolicy do
end
end
%i[submit?].each do |action|
permissions(action) do
context 'when teacher-defined assessments are available' do
before { create(:test_file, context: exercise) }
it 'grants access to anyone' do
%i[admin external_user teacher].each do |factory_name|
expect(policy).to permit(build(factory_name), exercise)
end
end
end
context 'when teacher-defined assessments are not available' do
it 'does not grant access to anyone' do
%i[admin external_user teacher].each do |factory_name|
expect(policy).not_to permit(build(factory_name), exercise)
end
end
end
end
end
describe ExercisePolicy::Scope do
describe '#resolve' do
let(:admin) { create(:admin) }