diff --git a/app/domains/accountify/contact.rb b/app/domains/accountify/contact.rb index 79f6052..e6c96d2 100644 --- a/app/domains/accountify/contact.rb +++ b/app/domains/accountify/contact.rb @@ -2,8 +2,6 @@ module Accountify module Contact extend self - class CreatedEvent < Event; end - def create(user_id:, tenant_id:, organisation_id:, first_name:, last_name:, email:) contact = nil @@ -18,7 +16,7 @@ def create(user_id:, tenant_id:, last_name: last_name, email: email) - event = CreatedEvent + event = Models::Contact::CreatedEvent .create!( user_id: user_id, tenant_id: tenant_id, @@ -58,8 +56,6 @@ def find_by_id(user_id:, tenant_id:, id:) } end - class UpdatedEvent < Event; end - def update(user_id:, tenant_id:, id:, first_name:, last_name:, email:) contact = nil @@ -74,7 +70,7 @@ def update(user_id:, tenant_id:, id:, last_name: last_name, email: email) - event = UpdatedEvent + event = Models::Contact::UpdatedEvent .create!( user_id: user_id, tenant_id: tenant_id, @@ -90,8 +86,6 @@ def update(user_id:, tenant_id:, id:, { id: contact.id, events: [{ id: event.id, type: event.type }] } end - class DeletedEvent < Event; end - def delete(user_id:, tenant_id:, id:, time: ::Time) contact = nil event = nil @@ -102,7 +96,7 @@ def delete(user_id:, tenant_id:, id:, time: ::Time) contact.update!(deleted_at: time.now.utc) - event = DeletedEvent + event = Models::Contact::DeletedEvent .create!( user_id: user_id, tenant_id: tenant_id, diff --git a/app/domains/accountify/invoice.rb b/app/domains/accountify/invoice.rb index 4cb361e..60f6fef 100644 --- a/app/domains/accountify/invoice.rb +++ b/app/domains/accountify/invoice.rb @@ -9,8 +9,6 @@ module Status VOIDED = 'voided' end - class DraftedEvent < Event; end - def draft(user_id:, tenant_id:, organisation_id:, contact_id:, currency_code:, due_date:, line_items:, @@ -51,7 +49,7 @@ def draft(user_id:, tenant_id:, quantity: line_item[:quantity]) end - event = DraftedEvent.create!( + event = Models::Invoice::DraftedEvent.create!( user_id: user_id, tenant_id: tenant_id, created_at: current_utc_time, @@ -118,8 +116,6 @@ def find_by_id(user_id:, tenant_id:, id:) } end - class UpdatedEvent < Event; end - def update(user_id:, tenant_id:, id:, organisation_id:, contact_id:, due_date:, line_items:, @@ -162,7 +158,7 @@ def update(user_id:, tenant_id:, id:, quantity: line_item[:quantity]) end - event = UpdatedEvent.create!( + event = Models::Invoice::UpdatedEvent.create!( user_id: user_id, tenant_id: tenant_id, created_at: current_utc_time, @@ -191,8 +187,6 @@ def update(user_id:, tenant_id:, id:, { id: invoice.id, events: [{ id: event.id, type: event.type }] } end - class DeletedEvent < Event; end - def delete(user_id:, tenant_id:, id:, time: ::Time) invoice = nil event = nil @@ -204,7 +198,7 @@ def delete(user_id:, tenant_id:, id:, time: ::Time) invoice.update!(updated_at: current_utc_time, deleted_at: current_utc_time) - event = DeletedEvent.create!( + event = Models::Invoice::DeletedEvent.create!( user_id: user_id, tenant_id: tenant_id, created_at: current_utc_time, @@ -219,8 +213,6 @@ def delete(user_id:, tenant_id:, id:, time: ::Time) { id: invoice.id, events: [{ id: event.id, type: event.type }] } end - class IssuedEvent < Event; end - def issue(user_id:, tenant_id:, id:, time: ::Time) invoice = nil event = nil @@ -235,7 +227,7 @@ def issue(user_id:, tenant_id:, id:, time: ::Time) issued_at: current_utc_time, updated_at: current_utc_time) - event = IssuedEvent.create!( + event = Models::Invoice::IssuedEvent.create!( user_id: user_id, tenant_id: tenant_id, created_at: current_utc_time, @@ -251,8 +243,6 @@ def issue(user_id:, tenant_id:, id:, time: ::Time) { id: invoice.id, events: [{ id: event.id, type: event.type }] } end - class PaidEvent < Event; end - def paid(user_id:, tenant_id:, id:, time: ::Time) invoice = nil event = nil @@ -268,7 +258,7 @@ def paid(user_id:, tenant_id:, id:, time: ::Time) invoice.update!(status: Invoice::Status::PAID, paid_at: Time.current) - event = PaidEvent.create!( + event = Models::Invoice::PaidEvent.create!( user_id: user_id, tenant_id: tenant_id, eventable: invoice, @@ -284,8 +274,6 @@ def paid(user_id:, tenant_id:, id:, time: ::Time) { id: invoice.id, events: [{ id: event.id, type: event.type }] } end - class VoidedEvent < Event; end - def void(user_id:, tenant_id:, id:, time: ::Time) invoice = nil event = nil @@ -295,7 +283,7 @@ def void(user_id:, tenant_id:, id:, time: ::Time) invoice.update!(status: Invoice::Status::VOIDED) - event = VoidedEvent.create!( + event = Models::Invoice::VoidedEvent.create!( user_id: user_id, tenant_id: tenant_id, eventable: invoice, diff --git a/app/domains/accountify/models/contact/created_event.rb b/app/domains/accountify/models/contact/created_event.rb new file mode 100644 index 0000000..9364833 --- /dev/null +++ b/app/domains/accountify/models/contact/created_event.rb @@ -0,0 +1,9 @@ +module Accountify + module Models + class Contact + class CreatedEvent < Models::Event + + end + end + end +end diff --git a/app/domains/accountify/models/contact/deleted_event.rb b/app/domains/accountify/models/contact/deleted_event.rb new file mode 100644 index 0000000..4879887 --- /dev/null +++ b/app/domains/accountify/models/contact/deleted_event.rb @@ -0,0 +1,9 @@ +module Accountify + module Models + class Contact + class DeletedEvent < Models::Event + + end + end + end +end diff --git a/app/domains/accountify/models/contact/updated_event.rb b/app/domains/accountify/models/contact/updated_event.rb new file mode 100644 index 0000000..73c745d --- /dev/null +++ b/app/domains/accountify/models/contact/updated_event.rb @@ -0,0 +1,9 @@ +module Accountify + module Models + class Contact + class UpdatedEvent < Models::Event + + end + end + end +end diff --git a/app/domains/accountify/models/event.rb b/app/domains/accountify/models/event.rb new file mode 100644 index 0000000..d75a4d2 --- /dev/null +++ b/app/domains/accountify/models/event.rb @@ -0,0 +1,7 @@ +module Accountify + module Models + class Event < ::Models::Event + + end + end +end diff --git a/app/domains/accountify/models/invoice.rb b/app/domains/accountify/models/invoice.rb index 807970f..d0a3356 100644 --- a/app/domains/accountify/models/invoice.rb +++ b/app/domains/accountify/models/invoice.rb @@ -7,8 +7,7 @@ class Invoice < ActiveRecord::Base has_many :line_items, -> { order(id: :asc) } - has_many :events, -> { order(created_at: :asc) }, - as: :eventable + has_many :events, -> { order(created_at: :asc) }, as: :eventable has_one :invoice_status_summary diff --git a/app/domains/accountify/models/invoice/deleted_event.rb b/app/domains/accountify/models/invoice/deleted_event.rb new file mode 100644 index 0000000..1f1cfdf --- /dev/null +++ b/app/domains/accountify/models/invoice/deleted_event.rb @@ -0,0 +1,9 @@ +module Accountify + module Models + class Invoice + class DeletedEvent < Models::Event + + end + end + end +end diff --git a/app/domains/accountify/models/invoice/drafted_event.rb b/app/domains/accountify/models/invoice/drafted_event.rb new file mode 100644 index 0000000..61e5b1d --- /dev/null +++ b/app/domains/accountify/models/invoice/drafted_event.rb @@ -0,0 +1,9 @@ +module Accountify + module Models + class Invoice + class DraftedEvent < Models::Event + + end + end + end +end diff --git a/app/domains/accountify/models/invoice/issued_event.rb b/app/domains/accountify/models/invoice/issued_event.rb new file mode 100644 index 0000000..9e29489 --- /dev/null +++ b/app/domains/accountify/models/invoice/issued_event.rb @@ -0,0 +1,9 @@ +module Accountify + module Models + class Invoice + class IssuedEvent < Models::Event + + end + end + end +end diff --git a/app/domains/accountify/models/invoice/paid_event.rb b/app/domains/accountify/models/invoice/paid_event.rb new file mode 100644 index 0000000..66507f4 --- /dev/null +++ b/app/domains/accountify/models/invoice/paid_event.rb @@ -0,0 +1,9 @@ +module Accountify + module Models + class Invoice + class PaidEvent < Models::Event + + end + end + end +end diff --git a/app/domains/accountify/models/invoice/updated_event.rb b/app/domains/accountify/models/invoice/updated_event.rb new file mode 100644 index 0000000..6bc3b5b --- /dev/null +++ b/app/domains/accountify/models/invoice/updated_event.rb @@ -0,0 +1,9 @@ +module Accountify + module Models + class Invoice + class UpdatedEvent < Models::Event + + end + end + end +end diff --git a/app/domains/accountify/models/invoice/voided_event.rb b/app/domains/accountify/models/invoice/voided_event.rb new file mode 100644 index 0000000..18c4f48 --- /dev/null +++ b/app/domains/accountify/models/invoice/voided_event.rb @@ -0,0 +1,9 @@ +module Accountify + module Models + class Invoice + class VoidedEvent < Models::Event + + end + end + end +end diff --git a/app/domains/accountify/models/organisation.rb b/app/domains/accountify/models/organisation.rb index 2ee0ec6..0e687a5 100644 --- a/app/domains/accountify/models/organisation.rb +++ b/app/domains/accountify/models/organisation.rb @@ -3,7 +3,7 @@ module Models class Organisation < ActiveRecord::Base self.table_name = 'accountify_organisations' - has_many :events, -> { order(created_at: :asc) }, as: :eventable + has_many :events, -> { order(created_at: :asc) }, as: :eventable, class_name: 'Models::Event' has_one :invoice_status_summary end diff --git a/app/domains/accountify/models/organisation/created_event.rb b/app/domains/accountify/models/organisation/created_event.rb new file mode 100644 index 0000000..b0b28c0 --- /dev/null +++ b/app/domains/accountify/models/organisation/created_event.rb @@ -0,0 +1,9 @@ +module Accountify + module Models + class Organisation + class CreatedEvent < Models::Event + + end + end + end +end diff --git a/app/domains/accountify/models/organisation/deleted_event.rb b/app/domains/accountify/models/organisation/deleted_event.rb new file mode 100644 index 0000000..15fe82e --- /dev/null +++ b/app/domains/accountify/models/organisation/deleted_event.rb @@ -0,0 +1,9 @@ +module Accountify + module Models + class Organisation + class DeletedEvent < Models::Event + + end + end + end +end diff --git a/app/domains/accountify/models/organisation/updated_event.rb b/app/domains/accountify/models/organisation/updated_event.rb new file mode 100644 index 0000000..84a230c --- /dev/null +++ b/app/domains/accountify/models/organisation/updated_event.rb @@ -0,0 +1,9 @@ +module Accountify + module Models + class Organisation + class UpdatedEvent < Models::Event + + end + end + end +end diff --git a/app/domains/accountify/organisation.rb b/app/domains/accountify/organisation.rb index 1a68daa..40ef7c4 100644 --- a/app/domains/accountify/organisation.rb +++ b/app/domains/accountify/organisation.rb @@ -2,8 +2,6 @@ module Accountify module Organisation extend self - class CreatedEvent < Event; end - def create(user_id:, tenant_id:, name:) organisation = nil event = nil @@ -13,7 +11,7 @@ def create(user_id:, tenant_id:, name:) .where(tenant_id: tenant_id) .create!(name: name) - event = CreatedEvent + event = Models::Organisation::CreatedEvent .where(user_id: user_id, tenant_id: tenant_id) .create!( eventable: organisation, @@ -48,8 +46,6 @@ def find_by_id(user_id:, tenant_id:, id:) } end - class UpdatedEvent < Event; end - def update(user_id:, tenant_id:, id:, name:) organisation = nil event = nil @@ -60,7 +56,7 @@ def update(user_id:, tenant_id:, id:, name:) organisation.update!(name: name) - event = UpdatedEvent + event = Models::Organisation::UpdatedEvent .where(user_id: user_id, tenant_id: tenant_id) .create!( eventable: organisation, @@ -73,8 +69,6 @@ def update(user_id:, tenant_id:, id:, name:) { id: organisation.id, events: [{ id: event.id, type: event.type }] } end - class DeletedEvent < Event; end - def delete(user_id:, tenant_id:, id:, time: ::Time) organisation = nil event = nil @@ -85,7 +79,7 @@ def delete(user_id:, tenant_id:, id:, time: ::Time) organisation.update!(deleted_at: time.now.utc) - event = DeletedEvent + event = Models::Organisation::DeletedEvent .where(user_id: user_id, tenant_id: tenant_id) .create!( eventable: organisation, diff --git a/app/domains/models/event.rb b/app/domains/models/event.rb new file mode 100644 index 0000000..cb9f466 --- /dev/null +++ b/app/domains/models/event.rb @@ -0,0 +1,21 @@ +module Models + class Event < ActiveRecord::Base + self.table_name = 'events' + + # associations + + belongs_to :eventable, polymorphic: true + + # validations + + validates :user_id, presence: true + validates :tenant_id, presence: true + + validates :type, presence: true, length: { maximum: 255 } + + validates :eventable_type, presence: true, length: { maximum: 255 }, + if: -> { eventable_id.present? } + + validates :eventable_id, presence: true, if: -> { eventable_type.present? } + end +end diff --git a/app/jobs/outboxer_integration/message/publish_job.rb b/app/jobs/outboxer_integration/message/publish_job.rb index ab24f92..30bee08 100644 --- a/app/jobs/outboxer_integration/message/publish_job.rb +++ b/app/jobs/outboxer_integration/message/publish_job.rb @@ -11,42 +11,42 @@ def perform(args) end case args['messageable_type'] - when 'Accountify::Organisation::CreatedEvent' + when 'Accountify::Models::Organisation::CreatedEvent' Accountify::InvoiceStatusSummary::GenerateJob.perform_async({ 'tenant_id' => messageable.tenant_id, 'organisation_id' => messageable.body['organisation']['id'] }) - when 'Accountify::Invoice::DraftedEvent' + when 'Accountify::Models::Invoice::DraftedEvent' Accountify::InvoiceStatusSummary::RegenerateJob.perform_async({ 'tenant_id' => messageable.tenant_id, 'organisation_id' => messageable.body['organisation']['id'], 'invoice_updated_at' => messageable.created_at.utc.iso8601 }) - when 'Accountify::Invoice::UpdatedEvent' + when 'Accountify::Models::Invoice::UpdatedEvent' Accountify::InvoiceStatusSummary::RegenerateJob.perform_async({ 'tenant_id' => messageable.tenant_id, 'organisation_id' => messageable.body['organisation']['id'], 'invoice_updated_at' => messageable.created_at.utc.iso8601 }) - when 'Accountify::Invoice::IssuedEvent' + when 'Accountify::Models::Invoice::IssuedEvent' Accountify::InvoiceStatusSummary::RegenerateJob.perform_async({ 'tenant_id' => messageable.tenant_id, 'organisation_id' => messageable.body['organisation']['id'], 'invoice_updated_at' => messageable.created_at.utc.iso8601 }) - when 'Accountify::Invoice::PaidEvent' + when 'Accountify::Models::Invoice::PaidEvent' Accountify::InvoiceStatusSummary::RegenerateJob.perform_async({ 'tenant_id' => messageable.tenant_id, 'organisation_id' => messageable.body['organisation']['id'], 'invoice_updated_at' => messageable.created_at.utc.iso8601 }) - when 'Accountify::Invoice::VoidedEvent' + when 'Accountify::Models::Invoice::VoidedEvent' Accountify::InvoiceStatusSummary::RegenerateJob.perform_async({ 'tenant_id' => messageable.tenant_id, 'organisation_id' => messageable.body['organisation']['id'], 'invoice_updated_at' => messageable.created_at.utc.iso8601 }) - when 'Accountify::Invoice::DeletedEvent' + when 'Accountify::Models::Invoice::DeletedEvent' Accountify::InvoiceStatusSummary::RegenerateJob.perform_async({ 'tenant_id' => messageable.tenant_id, 'organisation_id' => messageable.body['organisation']['id'], diff --git a/app/models/event.rb b/app/models/event.rb deleted file mode 100644 index dbc5573..0000000 --- a/app/models/event.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Event < ActiveRecord::Base - self.table_name = 'events' - - # associations - - belongs_to :eventable, polymorphic: true - - # validations - - validates :user_id, presence: true - validates :tenant_id, presence: true - - validates :type, presence: true, length: { maximum: 255 } - - validates :eventable_type, presence: true, length: { maximum: 255 }, - if: -> { eventable_id.present? } - - validates :eventable_id, presence: true, if: -> { eventable_type.present? } -end diff --git a/spec/controllers/accountify/invoice_controller/create_spec.rb b/spec/controllers/accountify/invoice_controller/create_spec.rb index 9c017f7..a477bca 100644 --- a/spec/controllers/accountify/invoice_controller/create_spec.rb +++ b/spec/controllers/accountify/invoice_controller/create_spec.rb @@ -48,7 +48,7 @@ module Accountify end let(:event) do - Invoice::DraftedEvent + Models::Invoice::DraftedEvent .where(tenant_id: tenant_id) .find_by!(id: response_body_json['events'].last['id']) end diff --git a/spec/controllers/accountify/invoice_controller/delete_spec.rb b/spec/controllers/accountify/invoice_controller/delete_spec.rb index b6ecaaf..27f7ae3 100644 --- a/spec/controllers/accountify/invoice_controller/delete_spec.rb +++ b/spec/controllers/accountify/invoice_controller/delete_spec.rb @@ -51,7 +51,7 @@ module Accountify let!(:response_body_json) { JSON.parse(response.body) } let(:event) do - Invoice::DeletedEvent + Models::Invoice::DeletedEvent .where(tenant_id: tenant_id) .find_by!(id: response_body_json['events'].last['id']) end diff --git a/spec/controllers/accountify/invoice_controller/issue_spec.rb b/spec/controllers/accountify/invoice_controller/issue_spec.rb index 131ac4a..a9291fd 100644 --- a/spec/controllers/accountify/invoice_controller/issue_spec.rb +++ b/spec/controllers/accountify/invoice_controller/issue_spec.rb @@ -52,7 +52,7 @@ module Accountify let!(:response_body_json) { JSON.parse(response.body) } let(:event) do - Invoice::IssuedEvent + Models::Invoice::IssuedEvent .where(tenant_id: tenant_id) .find_by!(id: response_body_json['events'].last['id']) end diff --git a/spec/controllers/accountify/invoice_controller/paid_spec.rb b/spec/controllers/accountify/invoice_controller/paid_spec.rb index 7a8abf1..018c4fa 100644 --- a/spec/controllers/accountify/invoice_controller/paid_spec.rb +++ b/spec/controllers/accountify/invoice_controller/paid_spec.rb @@ -52,7 +52,7 @@ module Accountify let!(:response_body_json) { JSON.parse(response.body) } let(:event) do - Invoice::PaidEvent + Models::Invoice::PaidEvent .where(tenant_id: tenant_id) .find_by!(id: response_body_json['events'].last['id']) end diff --git a/spec/controllers/accountify/invoice_controller/update_spec.rb b/spec/controllers/accountify/invoice_controller/update_spec.rb index c36842a..0008751 100644 --- a/spec/controllers/accountify/invoice_controller/update_spec.rb +++ b/spec/controllers/accountify/invoice_controller/update_spec.rb @@ -75,7 +75,7 @@ module Accountify let!(:response_body_json) { JSON.parse(response.body) } let(:event) do - Invoice::UpdatedEvent + Models::Invoice::UpdatedEvent .where(tenant_id: tenant_id) .find_by!(id: response_body_json['events'].last['id']) end diff --git a/spec/controllers/accountify/invoice_controller/void_spec.rb b/spec/controllers/accountify/invoice_controller/void_spec.rb index ac8c1c1..8b0ef7f 100644 --- a/spec/controllers/accountify/invoice_controller/void_spec.rb +++ b/spec/controllers/accountify/invoice_controller/void_spec.rb @@ -52,7 +52,7 @@ module Accountify let!(:response_body_json) { JSON.parse(response.body) } let(:event) do - Invoice::VoidedEvent + Models::Invoice::VoidedEvent .where(tenant_id: tenant_id) .find_by!(id: response_body_json['events'].last['id']) end diff --git a/spec/factories/events.rb b/spec/factories/events.rb index 2f259dd..3fdcb66 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -1,25 +1,25 @@ FactoryBot.define do - factory :event, class: 'Event' do + factory :event, class: 'Models::Event' do end - factory :accountify_organisation_created_event, class: 'Accountify::Organisation::CreatedEvent', parent: :event do + factory :accountify_organisation_created_event, class: 'Accountify::Models::Organisation::CreatedEvent', parent: :event do end - factory :accountify_invoice_drafted_event, class: 'Accountify::Invoice::DraftedEvent', parent: :event do + factory :accountify_invoice_drafted_event, class: 'Accountify::Models::Invoice::DraftedEvent', parent: :event do end - factory :accountify_invoice_updated_event, class: 'Accountify::Invoice::UpdatedEvent', parent: :event do + factory :accountify_invoice_updated_event, class: 'Accountify::Models::Invoice::UpdatedEvent', parent: :event do end - factory :accountify_invoice_issued_event, class: 'Accountify::Invoice::IssuedEvent', parent: :event do + factory :accountify_invoice_issued_event, class: 'Accountify::Models::Invoice::IssuedEvent', parent: :event do end - factory :accountify_invoice_paid_event, class: 'Accountify::Invoice::PaidEvent', parent: :event do + factory :accountify_invoice_paid_event, class: 'Accountify::Models::Invoice::PaidEvent', parent: :event do end - factory :accountify_invoice_voided_event, class: 'Accountify::Invoice::VoidedEvent', parent: :event do + factory :accountify_invoice_voided_event, class: 'Accountify::Models::Invoice::VoidedEvent', parent: :event do end - factory :accountify_invoice_deleted_event, class: 'Accountify::Invoice::DeletedEvent', parent: :event do + factory :accountify_invoice_deleted_event, class: 'Accountify::Models::Invoice::DeletedEvent', parent: :event do end end diff --git a/spec/jobs/outboxer_integration/message/publish_job_spec.rb b/spec/jobs/outboxer_integration/message/publish_job_spec.rb index 28aa3d3..a0c2570 100644 --- a/spec/jobs/outboxer_integration/message/publish_job_spec.rb +++ b/spec/jobs/outboxer_integration/message/publish_job_spec.rb @@ -22,7 +22,7 @@ module Message tenant_id: tenant_id, organisation_id: organisation.id, contact_id: contact.id) end - describe 'when Accountify::Organisation::CreatedEvent' do + describe 'when Accountify::Models::Organisation::CreatedEvent' do let(:event) do create( :accountify_organisation_created_event, @@ -34,7 +34,7 @@ module Message before do PublishJob.new.perform({ - 'messageable_type' => 'Accountify::Organisation::CreatedEvent', + 'messageable_type' => 'Accountify::Models::Organisation::CreatedEvent', 'messageable_id' => event.id }) end @@ -48,7 +48,7 @@ module Message end end - describe 'when Accountify::Invoice::DraftedEvent' do + describe 'when Accountify::Models::Invoice::DraftedEvent' do let(:event) do create( :accountify_invoice_drafted_event, @@ -62,7 +62,7 @@ module Message before do PublishJob.new.perform({ - 'messageable_type' => 'Accountify::Invoice::DraftedEvent', + 'messageable_type' => 'Accountify::Models::Invoice::DraftedEvent', 'messageable_id' => event.id }) end @@ -77,7 +77,7 @@ module Message end end - describe 'when Accountify::Invoice::UpdatedEvent' do + describe 'when Accountify::Models::Invoice::UpdatedEvent' do let(:event) do create( :accountify_invoice_updated_event, @@ -91,7 +91,7 @@ module Message before do PublishJob.new.perform({ - 'messageable_type' => 'Accountify::Invoice::UpdatedEvent', + 'messageable_type' => 'Accountify::Models::Invoice::UpdatedEvent', 'messageable_id' => event.id }) end @@ -106,7 +106,7 @@ module Message end end - describe 'when Accountify::Invoice::IssuedEvent' do + describe 'when Accountify::Models::Invoice::IssuedEvent' do let(:event) do create( :accountify_invoice_issued_event, @@ -120,7 +120,7 @@ module Message before do PublishJob.new.perform({ - 'messageable_type' => 'Accountify::Invoice::IssuedEvent', + 'messageable_type' => 'Accountify::Models::Invoice::IssuedEvent', 'messageable_id' => event.id }) end @@ -135,7 +135,7 @@ module Message end end - describe 'when Accountify::Invoice::PaidEvent' do + describe 'when Accountify::Models::Invoice::PaidEvent' do let(:event) do create( :accountify_invoice_paid_event, @@ -149,7 +149,7 @@ module Message before do PublishJob.new.perform({ - 'messageable_type' => 'Accountify::Invoice::PaidEvent', + 'messageable_type' => 'Accountify::Models::Invoice::PaidEvent', 'messageable_id' => event.id }) end @@ -164,7 +164,7 @@ module Message end end - describe 'when Accountify::Invoice::VoidedEvent' do + describe 'when Accountify::Models::Invoice::VoidedEvent' do let(:event) do create( :accountify_invoice_voided_event, @@ -178,7 +178,7 @@ module Message before do PublishJob.new.perform({ - 'messageable_type' => 'Accountify::Invoice::VoidedEvent', + 'messageable_type' => 'Accountify::Models::Invoice::VoidedEvent', 'messageable_id' => event.id }) end @@ -193,7 +193,7 @@ module Message end end - describe 'when Accountify::Invoice::DeletedEvent' do + describe 'when Accountify::Models::Invoice::DeletedEvent' do let(:event) do create( :accountify_invoice_deleted_event, @@ -207,7 +207,7 @@ module Message before do PublishJob.new.perform({ - 'messageable_type' => 'Accountify::Invoice::DeletedEvent', + 'messageable_type' => 'Accountify::Models::Invoice::DeletedEvent', 'messageable_id' => event.id }) end diff --git a/spec/lib/accountify/contact/create_spec.rb b/spec/lib/accountify/contact/create_spec.rb index cae0fe4..d2daa50 100644 --- a/spec/lib/accountify/contact/create_spec.rb +++ b/spec/lib/accountify/contact/create_spec.rb @@ -26,7 +26,7 @@ module Accountify end let(:event_model) do - Contact::CreatedEvent + Models::Contact::CreatedEvent .where(tenant_id: tenant_id) .find_by!(id: contact[:events].last[:id]) end diff --git a/spec/lib/accountify/contact/delete_spec.rb b/spec/lib/accountify/contact/delete_spec.rb index e83bf13..2a327f9 100644 --- a/spec/lib/accountify/contact/delete_spec.rb +++ b/spec/lib/accountify/contact/delete_spec.rb @@ -32,7 +32,7 @@ module Accountify end let(:event_model) do - Contact::DeletedEvent + Models::Contact::DeletedEvent .where(tenant_id: tenant_id) .find_by!(id: contact[:events].last[:id]) end diff --git a/spec/lib/accountify/contact/update_spec.rb b/spec/lib/accountify/contact/update_spec.rb index c4f989a..209fbad 100644 --- a/spec/lib/accountify/contact/update_spec.rb +++ b/spec/lib/accountify/contact/update_spec.rb @@ -36,7 +36,7 @@ module Accountify end let(:event_model) do - Contact::UpdatedEvent + Models::Contact::UpdatedEvent .where(tenant_id: tenant_id) .find_by!(id: contact[:events].last[:id]) end diff --git a/spec/lib/accountify/invoice/delete_spec.rb b/spec/lib/accountify/invoice/delete_spec.rb index 2ba0bd2..aa06cbf 100644 --- a/spec/lib/accountify/invoice/delete_spec.rb +++ b/spec/lib/accountify/invoice/delete_spec.rb @@ -57,7 +57,7 @@ module Accountify let(:invoice_model) { Models::Invoice.where(tenant_id: tenant_id).find_by!(id: id) } let(:event_model) do - Invoice::DeletedEvent.where(tenant_id: tenant_id).find_by!(id: invoice[:events].last[:id]) + Models::Invoice::DeletedEvent.where(tenant_id: tenant_id).find_by!(id: invoice[:events].last[:id]) end describe '.delete' do diff --git a/spec/lib/accountify/invoice/draft_spec.rb b/spec/lib/accountify/invoice/draft_spec.rb index ad12c83..35ab738 100644 --- a/spec/lib/accountify/invoice/draft_spec.rb +++ b/spec/lib/accountify/invoice/draft_spec.rb @@ -44,7 +44,8 @@ module Accountify end let(:event_model) do - Invoice::DraftedEvent.where(tenant_id: tenant_id).find_by!(id: invoice[:events].last[:id]) + Models::Invoice::DraftedEvent + .where(tenant_id: tenant_id).find_by!(id: invoice[:events].last[:id]) end describe '.draft' do diff --git a/spec/lib/accountify/invoice/issue_spec.rb b/spec/lib/accountify/invoice/issue_spec.rb index 9f8baf2..156ee27 100644 --- a/spec/lib/accountify/invoice/issue_spec.rb +++ b/spec/lib/accountify/invoice/issue_spec.rb @@ -57,7 +57,8 @@ module Accountify let(:invoice_model) { Models::Invoice.where(tenant_id: tenant_id).find_by!(id: id) } let(:event_model) do - Invoice::IssuedEvent.where(tenant_id: tenant_id).find_by!(id: invoice[:events].last[:id]) + Models::Invoice::IssuedEvent + .where(tenant_id: tenant_id).find_by!(id: invoice[:events].last[:id]) end describe '.issue' do diff --git a/spec/lib/accountify/invoice/paid_spec.rb b/spec/lib/accountify/invoice/paid_spec.rb index a8ed724..60b42f5 100644 --- a/spec/lib/accountify/invoice/paid_spec.rb +++ b/spec/lib/accountify/invoice/paid_spec.rb @@ -50,7 +50,7 @@ module Accountify end let(:event_model) do - Invoice::PaidEvent.where(tenant_id: tenant_id).find_by!(id: invoice[:events].last[:id]) + Models::Invoice::PaidEvent.where(tenant_id: tenant_id).find_by!(id: invoice[:events].last[:id]) end describe '.paid' do diff --git a/spec/lib/accountify/invoice/update_spec.rb b/spec/lib/accountify/invoice/update_spec.rb index 3140863..1ebeb93 100644 --- a/spec/lib/accountify/invoice/update_spec.rb +++ b/spec/lib/accountify/invoice/update_spec.rb @@ -86,7 +86,7 @@ module Accountify end let(:event_model) do - Invoice::UpdatedEvent + Models::Invoice::UpdatedEvent .where(tenant_id: tenant_id) .find_by!(id: invoice[:events].last[:id]) end diff --git a/spec/lib/accountify/invoice/void_spec.rb b/spec/lib/accountify/invoice/void_spec.rb index f547080..f428166 100644 --- a/spec/lib/accountify/invoice/void_spec.rb +++ b/spec/lib/accountify/invoice/void_spec.rb @@ -57,7 +57,8 @@ module Accountify let(:invoice_model) { Models::Invoice.where(tenant_id: tenant_id).find_by!(id: id) } let(:event_model) do - Invoice::VoidedEvent.where(tenant_id: tenant_id).find_by!(id: invoice[:events].last[:id]) + Models::Invoice::VoidedEvent + .where(tenant_id: tenant_id).find_by!(id: invoice[:events].last[:id]) end describe '.void' do diff --git a/spec/lib/accountify/organisation/create_spec.rb b/spec/lib/accountify/organisation/create_spec.rb index ef371ba..d9ef4f9 100644 --- a/spec/lib/accountify/organisation/create_spec.rb +++ b/spec/lib/accountify/organisation/create_spec.rb @@ -17,7 +17,7 @@ module Accountify end let(:event_model) do - Organisation::CreatedEvent + Models::Organisation::CreatedEvent .where(tenant_id: tenant_id) .find_by!(id: organisation[:events].last[:id]) end diff --git a/spec/lib/accountify/organisation/delete_spec.rb b/spec/lib/accountify/organisation/delete_spec.rb index 624d177..272afff 100644 --- a/spec/lib/accountify/organisation/delete_spec.rb +++ b/spec/lib/accountify/organisation/delete_spec.rb @@ -21,7 +21,7 @@ module Accountify end let(:event_model) do - Organisation::DeletedEvent + Models::Organisation::DeletedEvent .where(tenant_id: tenant_id) .find_by!(id: organisation[:events].last[:id]) end diff --git a/spec/lib/accountify/organisation/update_spec.rb b/spec/lib/accountify/organisation/update_spec.rb index 0bd1bf9..fa72086 100644 --- a/spec/lib/accountify/organisation/update_spec.rb +++ b/spec/lib/accountify/organisation/update_spec.rb @@ -21,7 +21,7 @@ module Accountify end let(:event_model) do - Organisation::UpdatedEvent + Models::Organisation::UpdatedEvent .where(tenant_id: tenant_id) .find_by!(id: organisation[:events].last[:id]) end