Skip verification of Docker image if pool size is empty
This commit is contained in:
@ -78,7 +78,8 @@ class ExecutionEnvironment < ApplicationRecord
|
||||
end
|
||||
|
||||
def validate_docker_image?
|
||||
docker_image.present? && !Rails.env.test?
|
||||
# We only validate the code execution with the provided image if there is at least one container to test with.
|
||||
pool_size.positive? && docker_image.present? && !Rails.env.test?
|
||||
end
|
||||
|
||||
def working_docker_image?
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user