Add tests for synchronizing all execution environments
This adds policy tests to ensure only an admin can synchronize all execution environments. It also adds controller tests that check that all execution environments get synchronized.
This commit is contained in:

committed by
Sebastian Serth

parent
598de3bcff
commit
0280c0282e
@ -192,4 +192,20 @@ describe ExecutionEnvironmentsController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#synchronize_all_to_poseidon' do
|
||||||
|
let(:execution_environments) { FactoryBot.build_list(:ruby, 3) }
|
||||||
|
|
||||||
|
it 'copies all execution environments to Poseidon' do
|
||||||
|
allow(ExecutionEnvironment).to receive(:all).and_return(execution_environments)
|
||||||
|
|
||||||
|
execution_environments.each do |execution_environment|
|
||||||
|
allow(execution_environment).to receive(:copy_to_poseidon).and_return(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
post :synchronize_all_to_poseidon
|
||||||
|
|
||||||
|
expect(execution_environments).to all(have_received(:copy_to_poseidon).once)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -58,4 +58,20 @@ describe ExecutionEnvironmentPolicy do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
permissions(:synchronize_all_to_poseidon?) do
|
||||||
|
it 'grants access to the admin' do
|
||||||
|
expect(policy).to permit(FactoryBot.build(:admin))
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples 'it does not grant access' do |user|
|
||||||
|
it "does not grant access to a user with role #{user.role}" do
|
||||||
|
expect(policy).not_to permit(user)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
%i[teacher external_user].each do |user|
|
||||||
|
include_examples 'it does not grant access', FactoryBot.build(user)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user