forbid users to import an exercise they do not have access to (previously a new one was created)

This commit is contained in:
Karol
2019-12-18 17:52:34 +01:00
parent 12c76b2fe4
commit f49cd0bed4
5 changed files with 24 additions and 4 deletions

View File

@ -489,6 +489,15 @@ describe ExercisesController do
end
end
context 'when import fails with ExerciseNotOwned' do
before { allow(ProformaService::Import).to receive(:call).and_raise(Proforma::ExerciseNotOwned) }
it 'responds with correct status code' do
post_request
expect(response).to have_http_status(:unauthorized)
end
end
context 'when import fails due to another error' do
before { allow(ProformaService::Import).to receive(:call).and_raise(StandardError) }