Skip to content

Commit

Permalink
Fixed NR events, added Mixpanel events to spec
Browse files Browse the repository at this point in the history
  • Loading branch information
millerti committed Jan 13, 2025
1 parent f154940 commit f9b2ce9
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions app/spec/controllers/webhooks/pinwheel/events_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,20 @@
}
end

it "creates a PinwheelAccount object" do
expect(NewRelicEventTracker).to receive(:track)
.with("PinwheelAccountCreated", {
it "creates a PinwheelAccount object and logs events" do
expect_any_instance_of(MixpanelEventTracker).to receive(:track)
.with("PinwheelAccountCreated", anything, hash_including(
cbv_flow_id: cbv_flow.id,
invitation_id: cbv_flow.cbv_flow_invitation_id,
platform_name: "acme"
})
))

expect_any_instance_of(NewRelicEventTracker).to receive(:track)
.with("PinwheelAccountCreated", anything, hash_including(
cbv_flow_id: cbv_flow.id,
invitation_id: cbv_flow.cbv_flow_invitation_id,
platform_name: "acme"
))

expect do
post :create, params: valid_params
Expand Down Expand Up @@ -96,16 +103,17 @@
.to(within(1.second).of(Time.now))
end

it "sends a NewRelic event when fully synced" do
it "sends events when fully synced" do
pinwheel_account.update(
created_at: 5.minutes.ago,
employment_synced_at: Time.now,
income_synced_at: Time.now,
identity_synced_at: Time.now,
identity_errored_at: Time.now
)
expect(NewRelicEventTracker).to receive(:track)
.with("PinwheelAccountSyncFinished", {

expect_any_instance_of(MixpanelEventTracker).to receive(:track)
.with("ApplicantFinishedPinwheelSync", anything, hash_including(
cbv_flow_id: cbv_flow.id,
invitation_id: cbv_flow.cbv_flow_invitation_id,
identity_success: false,
Expand All @@ -117,7 +125,22 @@
paystubs_success: true,
paystubs_supported: true,
sync_duration_seconds: within(1.second).of(5.minutes)
})
))

expect_any_instance_of(NewRelicEventTracker).to receive(:track)
.with("ApplicantFinishedPinwheelSync", anything, hash_including(
cbv_flow_id: cbv_flow.id,
invitation_id: cbv_flow.cbv_flow_invitation_id,
identity_success: false,
identity_supported: true,
income_success: true,
income_supported: true,
employment_success: true,
employment_supported: true,
paystubs_success: true,
paystubs_supported: true,
sync_duration_seconds: within(1.second).of(5.minutes)
))

post :create, params: valid_params
end
Expand Down

0 comments on commit f9b2ce9

Please sign in to comment.