Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing json attribute to Gush::Job #114

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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