Add validation for max_timeout in Ci::Runner

This commit is contained in:
Tomasz Maczukin 2018-03-21 17:34:55 +01:00
parent c747d9bc0b
commit 7d7b0688b8
No known key found for this signature in database
GPG key ID: 7E9EB2E4B0F625CD
2 changed files with 5 additions and 1 deletions

View file

@ -54,6 +54,10 @@ module Ci
chronic_duration_attr :maximum_timeout_human_readable, :maximum_timeout
validates :maximum_timeout, allow_nil: true,
numericality: { greater_than_or_equal_to: 600,
message: 'needs to be at least 10 minutes' }
# Searches for runners matching the given query.
#
# This method uses ILIKE on PostgreSQL and LIKE on MySQL.

View file

@ -1299,7 +1299,7 @@ describe Ci::Build do
end
context 'when runner sets timeout to smaller value' do
let(:runner2) { create(:ci_runner, maximum_timeout: 500) }
let(:runner2) { create(:ci_runner, maximum_timeout: 600) }
let(:build) { create(:ci_build, :pending, pipeline: pipeline2, runner: runner2) }
it 'returns project timeout configuration' do