Skip to content

Commit

Permalink
Pass index through the API to support limiting the results.
Browse files Browse the repository at this point in the history
[#86160500]
  • Loading branch information
alexwelch committed Feb 3, 2015
1 parent ac73dc1 commit 61c19e3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/controllers/jobs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def destroy

def log
job = Job.find_by_key(params[:id])
log = job.log
log = job.log(params[:index])
respond_with log
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/job_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def destroy_job
dray_client.delete_job(self.key)
end

def log
dray_client.get_job_log(self.key)
def log(index)
dray_client.get_job_log(self.key, index: index)
end

private
Expand Down
4 changes: 2 additions & 2 deletions lib/panamax_agent/dray/client/jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def get_job(job_id)
get(jobs_path(job_id))
end

def get_job_log(job_id)
get(jobs_path(job_id, 'log'))
def get_job_log(job_id, options={})
get(jobs_path(job_id, 'log'), options)
end

def delete_job(job_id)
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/jobs_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@
let(:log) { { 'lines' => [] } }

before do
allow_any_instance_of(Job).to receive(:log).and_return(log)
allow_any_instance_of(Job).to receive(:log).with(3).and_return(log)
end

it 'returns the log data' do
get :log, id: Job.first.key, format: :json
get :log, id: Job.first.key, index: 3, format: :json
expect(response.body).to eq(log.to_json)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/panamax_agent/dray/client/jobs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
describe '#get_job_log' do

it 'GETs the job log' do
expect(subject).to receive(:get).with("/jobs/#{job_id}/log").and_return(response)
subject.get_job_log(job_id)
expect(subject).to receive(:get).with("/jobs/#{job_id}/log", index: 3).and_return(response)
subject.get_job_log(job_id, index: 3)
end

describe '#delete_job' do
Expand Down
4 changes: 2 additions & 2 deletions spec/models/concerns/job_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@
end

it 'gets the job log from dray' do
expect(fake_dray_client).to receive(:get_job_log).with(subject.key)
subject.log
expect(fake_dray_client).to receive(:get_job_log).with(subject.key, index: 3)
subject.log(3)
end
end
end

0 comments on commit 61c19e3

Please sign in to comment.