Skip to content

Commit

Permalink
Correctly persist :wait attribute for Gush::Job (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
entei authored Jul 17, 2024
1 parent d49e6bb commit 6e87f60
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/gush/job.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module Gush
class Job
attr_accessor :workflow_id, :incoming, :outgoing, :params,
:finished_at, :failed_at, :started_at, :enqueued_at, :payloads,
:klass, :queue, :wait
:finished_at, :failed_at, :started_at, :enqueued_at, :payloads,
:klass, :queue, :wait
attr_reader :id, :klass, :output_payload, :params

def initialize(opts = {})
Expand All @@ -23,7 +23,8 @@ def as_json
failed_at: failed_at,
params: params,
workflow_id: workflow_id,
output_payload: output_payload
output_payload: output_payload,
wait: wait
}
end

Expand Down
11 changes: 9 additions & 2 deletions spec/gush/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@
describe "#as_json" do
context "finished and enqueued set to true" do
it "returns correct hash" do
job = described_class.new(workflow_id: 123, id: "702bced5-bb72-4bba-8f6f-15a3afa358bd", finished_at: 123, enqueued_at: 120)
job = described_class.new(
workflow_id: 123,
id: '702bced5-bb72-4bba-8f6f-15a3afa358bd',
finished_at: 123,
enqueued_at: 120,
wait: 300
)
expected = {
id: '702bced5-bb72-4bba-8f6f-15a3afa358bd',
klass: "Gush::Job",
Expand All @@ -83,7 +89,8 @@
params: {},
queue: nil,
output_payload: nil,
workflow_id: 123
workflow_id: 123,
wait: 300
}
expect(job.as_json).to eq(expected)
end
Expand Down

0 comments on commit 6e87f60

Please sign in to comment.