Skip to content

Commit 83da145

Browse files
authored
Refactor event created job event (#42)
* add specs * remove files
1 parent 2a13982 commit 83da145

File tree

7 files changed

+123
-106
lines changed

7 files changed

+123
-106
lines changed

app/jobs/event_created_job.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def perform(args)
1010
'tenant_id' => args['tenant_id'],
1111
'organisation_id' => args['organisation_id'] })
1212

13-
when 'Accountify::Invoice::IssuedEvent'
13+
when 'Accountify::Invoice::DraftedEvent'
1414
Accountify::InvoiceStatusSummary::RegenerateJob.perform_async({
1515
'tenant_id' => args['tenant_id'],
1616
'organisation_id' => args['organisation_id'],
@@ -22,6 +22,12 @@ def perform(args)
2222
'organisation_id' => args['organisation_id'],
2323
'invoice_updated_at' => args['occurred_at'] })
2424

25+
when 'Accountify::Invoice::IssuedEvent'
26+
Accountify::InvoiceStatusSummary::RegenerateJob.perform_async({
27+
'tenant_id' => args['tenant_id'],
28+
'organisation_id' => args['organisation_id'],
29+
'invoice_updated_at' => args['occurred_at'] })
30+
2531
when 'Accountify::Invoice::PaidEvent'
2632
Accountify::InvoiceStatusSummary::RegenerateJob.perform_async({
2733
'tenant_id' => args['tenant_id'],

spec/jobs/event/created_job/accountify/invoice/deleted_event_spec.rb

Lines changed: 0 additions & 21 deletions
This file was deleted.

spec/jobs/event/created_job/accountify/invoice/issued_spec.rb

Lines changed: 0 additions & 21 deletions
This file was deleted.

spec/jobs/event/created_job/accountify/invoice/paid_spec.rb

Lines changed: 0 additions & 21 deletions
This file was deleted.

spec/jobs/event/created_job/accountify/invoice/updated_spec.rb

Lines changed: 0 additions & 21 deletions
This file was deleted.

spec/jobs/event/created_job/accountify/invoice/voided_spec.rb

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe EventCreatedJob, type: :job do
4+
let(:tenant_id) { 555 }
5+
6+
describe 'when Accountify::Organisation::CreatedEvent' do
7+
before do
8+
EventCreatedJob.new.perform({
9+
'tenant_id' => tenant_id,
10+
'type' => 'Accountify::Organisation::CreatedEvent' })
11+
end
12+
13+
it 'performs Accountify::InvoiceStatusSummary::GenerateJob async' do
14+
expect(Accountify::InvoiceStatusSummary::GenerateJob.jobs).to match([
15+
hash_including(
16+
'args' => [
17+
hash_including(
18+
'tenant_id' => tenant_id )])])
19+
end
20+
end
21+
22+
describe 'when Accountify::Invoice::DraftedEvent' do
23+
before do
24+
EventCreatedJob.new.perform({
25+
'tenant_id' => tenant_id,
26+
'type' => 'Accountify::Invoice::DraftedEvent' })
27+
end
28+
29+
it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do
30+
expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([
31+
hash_including(
32+
'args' => [
33+
hash_including(
34+
'tenant_id' => tenant_id )])])
35+
end
36+
end
37+
38+
describe 'when Accountify::Invoice::UpdatedEvent' do
39+
before do
40+
EventCreatedJob.new.perform({
41+
'tenant_id' => tenant_id,
42+
'type' => 'Accountify::Invoice::UpdatedEvent' })
43+
end
44+
45+
it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do
46+
expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([
47+
hash_including(
48+
'args' => [
49+
hash_including(
50+
'tenant_id' => tenant_id )])])
51+
end
52+
end
53+
54+
describe 'when Accountify::Invoice::IssuedEvent' do
55+
before do
56+
EventCreatedJob.new.perform({
57+
'tenant_id' => tenant_id,
58+
'type' => 'Accountify::Invoice::IssuedEvent' })
59+
end
60+
61+
it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do
62+
expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([
63+
hash_including(
64+
'args' => [
65+
hash_including(
66+
'tenant_id' => tenant_id )])])
67+
end
68+
end
69+
70+
describe 'when Accountify::Invoice::PaidEvent' do
71+
before do
72+
EventCreatedJob.new.perform({
73+
'tenant_id' => tenant_id,
74+
'type' => 'Accountify::Invoice::PaidEvent' })
75+
end
76+
77+
it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do
78+
expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([
79+
hash_including(
80+
'args' => [
81+
hash_including(
82+
'tenant_id' => tenant_id )])])
83+
end
84+
end
85+
describe 'when Accountify::Invoice::VoidedEvent' do
86+
before do
87+
EventCreatedJob.new.perform({
88+
'tenant_id' => tenant_id,
89+
'type' => 'Accountify::Invoice::VoidedEvent' })
90+
end
91+
92+
it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do
93+
expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([
94+
hash_including(
95+
'args' => [
96+
hash_including(
97+
'tenant_id' => tenant_id )])])
98+
end
99+
end
100+
101+
describe 'when Accountify::Invoice::DeletedEvent' do
102+
before do
103+
EventCreatedJob.new.perform({
104+
'tenant_id' => tenant_id,
105+
'type' => 'Accountify::Invoice::DeletedEvent' })
106+
end
107+
108+
it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do
109+
expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([
110+
hash_including(
111+
'args' => [
112+
hash_including(
113+
'tenant_id' => tenant_id )])])
114+
end
115+
end
116+
end

0 commit comments

Comments
 (0)