Skip to content

Commit

Permalink
Treat pending as error (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
allthesignals authored Nov 6, 2024
1 parent 4527f6f commit 2a8f0cf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/app/controllers/webhooks/pinwheel/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create
pinwheel_account = PinwheelAccount.find_by_pinwheel_account_id(params["payload"]["account_id"])
pinwheel_account.update!(PinwheelAccount::EVENTS_MAP[params["event"]] => Time.now) if pinwheel_account.present?

if params.dig("payload", "outcome") == "error"
if params.dig("payload", "outcome") == "error" || params.dig("payload", "outcome") == "pending"
pinwheel_account.update!(PinwheelAccount::EVENTS_ERRORS_MAP[params["event"]] => Time.now) if pinwheel_account.present?
end

Expand Down
19 changes: 19 additions & 0 deletions app/spec/controllers/webhooks/pinwheel/events_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,24 @@
post :create, params: valid_params
end
end

context "for an 'pending' event outcome" do
let(:event_name) { "paystubs.fully_synced" }
let(:payload) do
{
"account_id" => account_id,
"end_user_id" => cbv_flow.pinwheel_end_user_id,
"outcome" => "pending"
}
end
let(:pinwheel_account) { PinwheelAccount.create!(cbv_flow: cbv_flow, supported_jobs: supported_jobs, pinwheel_account_id: account_id) }

it "updates the PinwheelAccount object with an error state" do
expect { post :create, params: valid_params }
.to change { pinwheel_account.reload.paystubs_errored_at }
.from(nil)
.to(within(1.second).of(Time.now))
end
end
end
end

0 comments on commit 2a8f0cf

Please sign in to comment.