Skip verification of Docker image if pool size is empty

This commit is contained in:
Sebastian Serth
2021-11-09 17:37:11 +01:00
parent b179dadce6
commit fb92d382ac
3 changed files with 10 additions and 3 deletions

View File

@ -13,7 +13,7 @@ describe ExecutionEnvironmentsController do
describe 'POST #create' do
context 'with a valid execution environment' do
let(:perform_request) { proc { post :create, params: {execution_environment: FactoryBot.build(:ruby).attributes} } }
let(:perform_request) { proc { post :create, params: {execution_environment: FactoryBot.build(:ruby, pool_size: 1).attributes} } }
before do
allow(Rails.env).to receive(:test?).and_return(false, true)
@ -186,7 +186,7 @@ describe ExecutionEnvironmentsController do
runner = instance_double 'runner'
allow(Runner).to receive(:for).and_return(runner)
allow(runner).to receive(:execute_command).and_return({})
put :update, params: {execution_environment: FactoryBot.attributes_for(:ruby), id: execution_environment.id}
put :update, params: {execution_environment: FactoryBot.attributes_for(:ruby, pool_size: 1), id: execution_environment.id}
end
expect_assigns(docker_images: Array)

View File

@ -138,8 +138,14 @@ describe ExecutionEnvironment do
expect(execution_environment.send(:validate_docker_image?)).to be false
end
it 'is false when the pool size is empty' do
expect(execution_environment.pool_size).to be 0
expect(execution_environment.send(:validate_docker_image?)).to be false
end
it 'is true otherwise' do
execution_environment.docker_image = FactoryBot.attributes_for(:ruby)[:docker_image]
execution_environment.pool_size = 1
allow(Rails.env).to receive(:test?).and_return(false)
expect(execution_environment.send(:validate_docker_image?)).to be true
end