diff --git a/lib/api/runner.rb b/lib/api/runner.rb index 3a26155be6d..74ddaf26bb6 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -14,10 +14,10 @@ module API optional :locked, type: Boolean, desc: 'Should Runner be locked for current project' optional :run_untagged, type: Boolean, desc: 'Should Runner handle untagged jobs' optional :tag_list, type: Array[String], desc: %q(List of Runner's tags) - optional :maximum_job_timeout, type: Integer, desc: 'Maximum timeout set when this Runner will handle the job' + optional :maximum_job_timeout_human_readable, type: String, desc: 'Maximum timeout set when this Runner will handle the job' end post '/' do - attributes = attributes_for_keys([:description, :locked, :run_untagged, :tag_list, :maximum_job_timeout]) + attributes = attributes_for_keys([:description, :locked, :run_untagged, :tag_list, :maximum_job_timeout_human_readable]) .merge(get_runner_details_from_request) runner = diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index a6a4f510406..55c4150a393 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -112,10 +112,20 @@ describe API::Runner do context 'when maximum job timeout is specified' do it 'creates runner' do post api('/runners'), token: registration_token, - maximum_job_timeout: 7200 + maximum_job_timeout_human_readable: '2h 30m' expect(response).to have_gitlab_http_status 201 - expect(Ci::Runner.first.maximum_job_timeout).to eq(7200) + expect(Ci::Runner.first.maximum_job_timeout).to eq(9000) + end + + context 'when maximum job timeout is empty' do + it 'creates runner' do + post api('/runners'), token: registration_token, + maximum_job_timeout_human_readable: '' + + expect(response).to have_gitlab_http_status 201 + expect(Ci::Runner.first.maximum_job_timeout).to be_nil + end end end