Skip to content
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
8 changes: 7 additions & 1 deletion app/jobs/event_created_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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'],
Expand Down

This file was deleted.

21 changes: 0 additions & 21 deletions spec/jobs/event/created_job/accountify/invoice/issued_spec.rb

This file was deleted.

21 changes: 0 additions & 21 deletions spec/jobs/event/created_job/accountify/invoice/paid_spec.rb

This file was deleted.

21 changes: 0 additions & 21 deletions spec/jobs/event/created_job/accountify/invoice/updated_spec.rb

This file was deleted.

21 changes: 0 additions & 21 deletions spec/jobs/event/created_job/accountify/invoice/voided_spec.rb

This file was deleted.

116 changes: 116 additions & 0 deletions spec/jobs/event_created_job_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Loading