From 6786661a7dcaf2f113958afbe2b3b91a9e60d960 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 30 Nov 2024 21:08:48 +1100 Subject: [PATCH 1/2] add specs --- app/jobs/event_created_job.rb | 8 +- spec/jobs/event_created_job_spec.rb | 116 ++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 spec/jobs/event_created_job_spec.rb diff --git a/app/jobs/event_created_job.rb b/app/jobs/event_created_job.rb index c4ac6ea..bf7f778 100644 --- a/app/jobs/event_created_job.rb +++ b/app/jobs/event_created_job.rb @@ -10,7 +10,7 @@ def perform(args) 'tenant_id' => args['tenant_id'], 'organisation_id' => args['organisation_id'] }) - when 'Accountify::Invoice::IssuedEvent' + when 'Accountify::Invoice::DraftedEvent' Accountify::InvoiceStatusSummary::RegenerateJob.perform_async({ 'tenant_id' => args['tenant_id'], 'organisation_id' => args['organisation_id'], @@ -22,6 +22,12 @@ def perform(args) 'organisation_id' => args['organisation_id'], 'invoice_updated_at' => args['occurred_at'] }) + when 'Accountify::Invoice::IssuedEvent' + Accountify::InvoiceStatusSummary::RegenerateJob.perform_async({ + 'tenant_id' => args['tenant_id'], + 'organisation_id' => args['organisation_id'], + 'invoice_updated_at' => args['occurred_at'] }) + when 'Accountify::Invoice::PaidEvent' Accountify::InvoiceStatusSummary::RegenerateJob.perform_async({ 'tenant_id' => args['tenant_id'], diff --git a/spec/jobs/event_created_job_spec.rb b/spec/jobs/event_created_job_spec.rb new file mode 100644 index 0000000..bb8cc3b --- /dev/null +++ b/spec/jobs/event_created_job_spec.rb @@ -0,0 +1,116 @@ +require 'rails_helper' + +RSpec.describe EventCreatedJob, type: :job do + let(:tenant_id) { 555 } + + describe 'when Accountify::Organisation::CreatedEvent' do + before do + EventCreatedJob.new.perform({ + 'tenant_id' => tenant_id, + 'type' => 'Accountify::Organisation::CreatedEvent' }) + end + + it 'performs Accountify::InvoiceStatusSummary::GenerateJob async' do + expect(Accountify::InvoiceStatusSummary::GenerateJob.jobs).to match([ + hash_including( + 'args' => [ + hash_including( + 'tenant_id' => tenant_id )])]) + end + end + + describe 'when Accountify::Invoice::DraftedEvent' do + before do + EventCreatedJob.new.perform({ + 'tenant_id' => tenant_id, + 'type' => 'Accountify::Invoice::DraftedEvent' }) + end + + it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do + expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([ + hash_including( + 'args' => [ + hash_including( + 'tenant_id' => tenant_id )])]) + end + end + + describe 'when Accountify::Invoice::UpdatedEvent' do + before do + EventCreatedJob.new.perform({ + 'tenant_id' => tenant_id, + 'type' => 'Accountify::Invoice::UpdatedEvent' }) + end + + it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do + expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([ + hash_including( + 'args' => [ + hash_including( + 'tenant_id' => tenant_id )])]) + end + end + + describe 'when Accountify::Invoice::IssuedEvent' do + before do + EventCreatedJob.new.perform({ + 'tenant_id' => tenant_id, + 'type' => 'Accountify::Invoice::IssuedEvent' }) + end + + it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do + expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([ + hash_including( + 'args' => [ + hash_including( + 'tenant_id' => tenant_id )])]) + end + end + + describe 'when Accountify::Invoice::PaidEvent' do + before do + EventCreatedJob.new.perform({ + 'tenant_id' => tenant_id, + 'type' => 'Accountify::Invoice::PaidEvent' }) + end + + it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do + expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([ + hash_including( + 'args' => [ + hash_including( + 'tenant_id' => tenant_id )])]) + end + end + describe 'when Accountify::Invoice::VoidedEvent' do + before do + EventCreatedJob.new.perform({ + 'tenant_id' => tenant_id, + 'type' => 'Accountify::Invoice::VoidedEvent' }) + end + + it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do + expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([ + hash_including( + 'args' => [ + hash_including( + 'tenant_id' => tenant_id )])]) + end + end + + describe 'when Accountify::Invoice::DeletedEvent' do + before do + EventCreatedJob.new.perform({ + 'tenant_id' => tenant_id, + 'type' => 'Accountify::Invoice::DeletedEvent' }) + end + + it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do + expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([ + hash_including( + 'args' => [ + hash_including( + 'tenant_id' => tenant_id )])]) + end + end +end From 577292656d0e6cc19ab9a71e8a554cfc99feb7d5 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 30 Nov 2024 21:10:22 +1100 Subject: [PATCH 2/2] remove files --- .../accountify/invoice/deleted_event_spec.rb | 21 ------------------- .../accountify/invoice/issued_spec.rb | 21 ------------------- .../accountify/invoice/paid_spec.rb | 21 ------------------- .../accountify/invoice/updated_spec.rb | 21 ------------------- .../accountify/invoice/voided_spec.rb | 21 ------------------- 5 files changed, 105 deletions(-) delete mode 100644 spec/jobs/event/created_job/accountify/invoice/deleted_event_spec.rb delete mode 100644 spec/jobs/event/created_job/accountify/invoice/issued_spec.rb delete mode 100644 spec/jobs/event/created_job/accountify/invoice/paid_spec.rb delete mode 100644 spec/jobs/event/created_job/accountify/invoice/updated_spec.rb delete mode 100644 spec/jobs/event/created_job/accountify/invoice/voided_spec.rb diff --git a/spec/jobs/event/created_job/accountify/invoice/deleted_event_spec.rb b/spec/jobs/event/created_job/accountify/invoice/deleted_event_spec.rb deleted file mode 100644 index 38a656e..0000000 --- a/spec/jobs/event/created_job/accountify/invoice/deleted_event_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -RSpec.describe EventCreatedJob, type: :job do - let(:tenant_id) { 555 } - - before do - EventCreatedJob.new.perform({ - 'tenant_id' => tenant_id, - 'type' => 'Accountify::Invoice::DeletedEvent' }) - end - - describe 'when Accountify::Invoice::DeletedEvent' do - it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do - expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([ - hash_including( - 'args' => [ - hash_including( - 'tenant_id' => tenant_id )])]) - end - end -end diff --git a/spec/jobs/event/created_job/accountify/invoice/issued_spec.rb b/spec/jobs/event/created_job/accountify/invoice/issued_spec.rb deleted file mode 100644 index 78b2343..0000000 --- a/spec/jobs/event/created_job/accountify/invoice/issued_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -RSpec.describe EventCreatedJob, type: :job do - let(:tenant_id) { 555 } - - before do - EventCreatedJob.new.perform({ - 'tenant_id' => tenant_id, - 'type' => 'Accountify::Invoice::IssuedEvent' }) - end - - describe 'when Accountify::Invoice::IssuedEvent' do - it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do - expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([ - hash_including( - 'args' => [ - hash_including( - 'tenant_id' => tenant_id )])]) - end - end -end diff --git a/spec/jobs/event/created_job/accountify/invoice/paid_spec.rb b/spec/jobs/event/created_job/accountify/invoice/paid_spec.rb deleted file mode 100644 index 0f55954..0000000 --- a/spec/jobs/event/created_job/accountify/invoice/paid_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -RSpec.describe EventCreatedJob, type: :job do - let(:tenant_id) { 555 } - - before do - EventCreatedJob.new.perform({ - 'tenant_id' => tenant_id, - 'type' => 'Accountify::Invoice::PaidEvent' }) - end - - describe 'when Accountify::Invoice::PaidEvent' do - it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do - expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([ - hash_including( - 'args' => [ - hash_including( - 'tenant_id' => tenant_id )])]) - end - end -end diff --git a/spec/jobs/event/created_job/accountify/invoice/updated_spec.rb b/spec/jobs/event/created_job/accountify/invoice/updated_spec.rb deleted file mode 100644 index a0ee35e..0000000 --- a/spec/jobs/event/created_job/accountify/invoice/updated_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -RSpec.describe EventCreatedJob, type: :job do - let(:tenant_id) { 555 } - - before do - EventCreatedJob.new.perform({ - 'tenant_id' => tenant_id, - 'type' => 'Accountify::Invoice::UpdatedEvent' }) - end - - describe 'when Accountify::Invoice::UpdatedEvent' do - it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do - expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([ - hash_including( - 'args' => [ - hash_including( - 'tenant_id' => tenant_id )])]) - end - end -end diff --git a/spec/jobs/event/created_job/accountify/invoice/voided_spec.rb b/spec/jobs/event/created_job/accountify/invoice/voided_spec.rb deleted file mode 100644 index 7f866e0..0000000 --- a/spec/jobs/event/created_job/accountify/invoice/voided_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -RSpec.describe EventCreatedJob, type: :job do - let(:tenant_id) { 555 } - - before do - EventCreatedJob.new.perform({ - 'tenant_id' => tenant_id, - 'type' => 'Accountify::Invoice::VoidedEvent' }) - end - - describe 'when Accountify::Invoice::VoidedEvent' do - it 'performs Accountify::InvoiceStatusSummary::RegenerateJob async' do - expect(Accountify::InvoiceStatusSummary::RegenerateJob.jobs).to match([ - hash_including( - 'args' => [ - hash_including( - 'tenant_id' => tenant_id )])]) - end - end -end