From cc6610c0fca9e2d106c46674ea25cb7acece5c0e Mon Sep 17 00:00:00 2001 From: Roger Ostrander Date: Wed, 6 Mar 2019 01:05:18 -0500 Subject: [PATCH] Add options to runner_jobs (#492) * Add options to runner_jobs * Whitespace cleanup --- lib/gitlab/client/runners.rb | 6 ++++-- spec/gitlab/client/runners_spec.rb | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/gitlab/client/runners.rb b/lib/gitlab/client/runners.rb index 056a7f656..a8976af59 100644 --- a/lib/gitlab/client/runners.rb +++ b/lib/gitlab/client/runners.rb @@ -79,9 +79,11 @@ def delete_runner(id) # Gitlab.runner_jobs(1) # # @param [Integer] id The ID of a runner. + # @param [Hash] options A customizable set of options. + # @option options [String] :status Status of the job; one of: running, success, failed, canceled # @return [Array] - def runner_jobs(runner_id) - get("/runners/#{url_encode runner_id}/jobs") + def runner_jobs(runner_id, options = {}) + get("/runners/#{url_encode runner_id}/jobs", query: options) end # List all runners (specific and shared) available in the project. Shared runners are listed if at least one shared runner is defined and shared runners usage is enabled in the project's settings. diff --git a/spec/gitlab/client/runners_spec.rb b/spec/gitlab/client/runners_spec.rb index c28b07938..14392e6bd 100644 --- a/spec/gitlab/client/runners_spec.rb +++ b/spec/gitlab/client/runners_spec.rb @@ -132,12 +132,12 @@ describe '.runner_jobs' do before do - stub_get('/runners/1/jobs', 'runner_jobs') - @jobs = Gitlab.runner_jobs(1) + stub_get('/runners/1/jobs?status=running', 'runner_jobs') + @jobs = Gitlab.runner_jobs(1, status: :running) end it 'gets the correct resource' do - expect(a_get('/runners/1/jobs')).to have_been_made + expect(a_get('/runners/1/jobs').with(query: { status: :running })).to have_been_made end end