From 1b11586ee22612134772b8923bdc487b2f8a40b2 Mon Sep 17 00:00:00 2001 From: Ivan Novosad Date: Mon, 25 Nov 2024 09:36:55 +0100 Subject: [PATCH] fix(unique-jobs): Unique jobs were not enqueuing jobs with keyword arguments --- app/jobs/fees/create_pay_in_advance_job.rb | 12 +++++++---- .../aggregator/credit_notes/create_job.rb | 6 +++++- .../aggregator/invoices/create_job.rb | 6 +++++- .../crm/create_customer_association_job.rb | 2 +- .../aggregator/invoices/crm/create_job.rb | 4 ++-- .../aggregator/invoices/crm/update_job.rb | 2 +- .../aggregator/payments/create_job.rb | 6 +++++- .../crm/create_customer_association_job.rb | 2 +- .../subscriptions/crm/create_job.rb | 4 ++-- .../subscriptions/crm/update_job.rb | 2 +- .../companies/deploy_properties_job.rb | 2 +- .../hubspot/contacts/deploy_properties_job.rb | 2 +- .../hubspot/invoices/deploy_object_job.rb | 2 +- .../hubspot/save_portal_id_job.rb | 2 +- .../subscriptions/deploy_object_job.rb | 2 +- .../create_pay_in_advance_charge_job.rb | 20 +++++++++++-------- app/services/events/pay_in_advance_service.rb | 4 ++-- .../aggregator/invoices/create_service.rb | 2 +- .../aggregator/payments/create_service.rb | 2 +- .../integrations/hubspot/create_service.rb | 2 +- app/services/invoices/add_on_service.rb | 4 ++-- .../invoices/advance_charges_service.rb | 4 ++-- .../invoices/create_one_off_service.rb | 4 ++-- .../create_pay_in_advance_charge_service.rb | 4 ++-- .../invoices/finalize_open_credit_service.rb | 4 ++-- app/services/invoices/paid_credit_service.rb | 4 ++-- .../invoices/payments/adyen_service.rb | 2 +- .../invoices/payments/gocardless_service.rb | 2 +- .../invoices/payments/stripe_service.rb | 2 +- .../invoices/progressive_billing_service.rb | 4 ++-- .../refresh_draft_and_finalize_service.rb | 4 ++-- app/services/invoices/retry_service.rb | 4 ++-- app/services/invoices/subscription_service.rb | 4 ++-- .../payments/adyen_service.rb | 2 +- .../payments/gocardless_service.rb | 2 +- config/application.rb | 2 ++ .../strategies/until_executed_patch.rb | 20 +++++++++++++++++++ .../fees/create_pay_in_advance_job_spec.rb | 2 +- .../credit_notes/create_job_spec.rb | 2 +- .../aggregator/invoices/create_job_spec.rb | 2 +- .../create_customer_association_job_spec.rb | 2 +- .../invoices/crm/create_job_spec.rb | 8 ++++---- .../invoices/crm/update_job_spec.rb | 2 +- .../aggregator/payments/create_job_spec.rb | 2 +- .../create_customer_association_job_spec.rb | 2 +- .../subscriptions/crm/create_job_spec.rb | 9 +++++---- .../subscriptions/crm/update_job_spec.rb | 2 +- .../companies/deploy_properties_job_spec.rb | 2 +- .../contacts/deploy_properties_job_spec.rb | 2 +- .../invoices/deploy_object_job_spec.rb | 2 +- .../hubspot/save_portal_id_job_spec.rb | 2 +- .../subscriptions/deploy_object_job_spec.rb | 2 +- .../create_pay_in_advance_charge_job_spec.rb | 12 +++++------ .../hubspot/create_service_spec.rb | 2 +- .../invoices/advance_charges_service_spec.rb | 2 +- .../finalize_open_credit_service_spec.rb | 2 +- 56 files changed, 131 insertions(+), 88 deletions(-) create mode 100644 lib/active_job/uniqueness/strategies/until_executed_patch.rb diff --git a/app/jobs/fees/create_pay_in_advance_job.rb b/app/jobs/fees/create_pay_in_advance_job.rb index 6c7fba33ba1..c3a9c3589db 100644 --- a/app/jobs/fees/create_pay_in_advance_job.rb +++ b/app/jobs/fees/create_pay_in_advance_job.rb @@ -4,7 +4,9 @@ module Fees class CreatePayInAdvanceJob < ApplicationJob queue_as :default - def perform(charge:, event:, billing_at: nil) + unique :until_executed, on_conflict: :log + + def perform(charge, event, billing_at = nil) result = Fees::CreatePayInAdvanceService.call(charge:, event:, billing_at:) return if !result.success? && tax_error?(result) @@ -13,9 +15,11 @@ def perform(charge:, event:, billing_at: nil) end def lock_key_arguments - args = arguments.first - event = Events::CommonFactory.new_instance(source: args[:event]) - [args[:charge], event.organization_id, event.external_subscription_id, event.transaction_id] + charge = arguments.first + arg_event = arguments.second + + event = Events::CommonFactory.new_instance(source: arg_event) + [charge, event.organization_id, event.external_subscription_id, event.transaction_id] end private diff --git a/app/jobs/integrations/aggregator/credit_notes/create_job.rb b/app/jobs/integrations/aggregator/credit_notes/create_job.rb index eb0bd189660..9ed8de1d251 100644 --- a/app/jobs/integrations/aggregator/credit_notes/create_job.rb +++ b/app/jobs/integrations/aggregator/credit_notes/create_job.rb @@ -6,10 +6,14 @@ module CreditNotes class CreateJob < ApplicationJob queue_as 'integrations' + # https://github.com/veeqo/activejob-uniqueness/issues/75 + # retry_on does not work with until_executed strategy + unique :until_executed_patch, on_conflict: :log + retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(credit_note:) + def perform(credit_note) result = Integrations::Aggregator::CreditNotes::CreateService.call(credit_note:) result.raise_if_error! end diff --git a/app/jobs/integrations/aggregator/invoices/create_job.rb b/app/jobs/integrations/aggregator/invoices/create_job.rb index 75218dd026a..8f975646300 100644 --- a/app/jobs/integrations/aggregator/invoices/create_job.rb +++ b/app/jobs/integrations/aggregator/invoices/create_job.rb @@ -6,10 +6,14 @@ module Invoices class CreateJob < ApplicationJob queue_as 'integrations' + # https://github.com/veeqo/activejob-uniqueness/issues/75 + # retry_on does not work with until_executed strategy + unique :until_executed_patch, on_conflict: :log + retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(invoice:) + def perform(invoice) result = Integrations::Aggregator::Invoices::CreateService.call(invoice:) result.raise_if_error! end diff --git a/app/jobs/integrations/aggregator/invoices/crm/create_customer_association_job.rb b/app/jobs/integrations/aggregator/invoices/crm/create_customer_association_job.rb index dbf980328b5..afa33cd7128 100644 --- a/app/jobs/integrations/aggregator/invoices/crm/create_customer_association_job.rb +++ b/app/jobs/integrations/aggregator/invoices/crm/create_customer_association_job.rb @@ -10,7 +10,7 @@ class CreateCustomerAssociationJob < ApplicationJob retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10 retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(invoice:) + def perform(invoice) result = Integrations::Aggregator::Invoices::Crm::CreateCustomerAssociationService.call(invoice:) result.raise_if_error! end diff --git a/app/jobs/integrations/aggregator/invoices/crm/create_job.rb b/app/jobs/integrations/aggregator/invoices/crm/create_job.rb index 44155e8a363..187bc657934 100644 --- a/app/jobs/integrations/aggregator/invoices/crm/create_job.rb +++ b/app/jobs/integrations/aggregator/invoices/crm/create_job.rb @@ -11,11 +11,11 @@ class CreateJob < ApplicationJob retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10 retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(invoice:) + def perform(invoice) result = Integrations::Aggregator::Invoices::Crm::CreateService.call(invoice:) if result.success? - Integrations::Aggregator::Invoices::Crm::CreateCustomerAssociationJob.perform_later(invoice:) + Integrations::Aggregator::Invoices::Crm::CreateCustomerAssociationJob.perform_later(invoice) end result.raise_if_error! diff --git a/app/jobs/integrations/aggregator/invoices/crm/update_job.rb b/app/jobs/integrations/aggregator/invoices/crm/update_job.rb index 45418dd6eea..16e91363f0f 100644 --- a/app/jobs/integrations/aggregator/invoices/crm/update_job.rb +++ b/app/jobs/integrations/aggregator/invoices/crm/update_job.rb @@ -11,7 +11,7 @@ class UpdateJob < ApplicationJob retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10 retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(invoice:) + def perform(invoice) result = Integrations::Aggregator::Invoices::Crm::UpdateService.call(invoice:) result.raise_if_error! end diff --git a/app/jobs/integrations/aggregator/payments/create_job.rb b/app/jobs/integrations/aggregator/payments/create_job.rb index dafba9a2c11..3c53075b208 100644 --- a/app/jobs/integrations/aggregator/payments/create_job.rb +++ b/app/jobs/integrations/aggregator/payments/create_job.rb @@ -6,11 +6,15 @@ module Payments class CreateJob < ApplicationJob queue_as 'integrations' + # https://github.com/veeqo/activejob-uniqueness/issues/75 + # retry_on does not work with until_executed strategy + unique :until_executed_patch, on_conflict: :log + retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 5 retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10 retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(payment:) + def perform(payment) result = Integrations::Aggregator::Payments::CreateService.call(payment:) result.raise_if_error! end diff --git a/app/jobs/integrations/aggregator/subscriptions/crm/create_customer_association_job.rb b/app/jobs/integrations/aggregator/subscriptions/crm/create_customer_association_job.rb index cfc36a76771..66be079f824 100644 --- a/app/jobs/integrations/aggregator/subscriptions/crm/create_customer_association_job.rb +++ b/app/jobs/integrations/aggregator/subscriptions/crm/create_customer_association_job.rb @@ -10,7 +10,7 @@ class CreateCustomerAssociationJob < ApplicationJob retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10 retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(subscription:) + def perform(subscription) result = Integrations::Aggregator::Subscriptions::Crm::CreateCustomerAssociationService.call(subscription:) result.raise_if_error! end diff --git a/app/jobs/integrations/aggregator/subscriptions/crm/create_job.rb b/app/jobs/integrations/aggregator/subscriptions/crm/create_job.rb index 0a2cf9ce63e..d6b001398b2 100644 --- a/app/jobs/integrations/aggregator/subscriptions/crm/create_job.rb +++ b/app/jobs/integrations/aggregator/subscriptions/crm/create_job.rb @@ -11,11 +11,11 @@ class CreateJob < ApplicationJob retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10 retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(subscription:) + def perform(subscription) result = Integrations::Aggregator::Subscriptions::Crm::CreateService.call(subscription:) if result.success? - Integrations::Aggregator::Subscriptions::Crm::CreateCustomerAssociationJob.perform_later(subscription:) + Integrations::Aggregator::Subscriptions::Crm::CreateCustomerAssociationJob.perform_later(subscription) end result.raise_if_error! diff --git a/app/jobs/integrations/aggregator/subscriptions/crm/update_job.rb b/app/jobs/integrations/aggregator/subscriptions/crm/update_job.rb index 8860fd0d9e8..5ef8010cb30 100644 --- a/app/jobs/integrations/aggregator/subscriptions/crm/update_job.rb +++ b/app/jobs/integrations/aggregator/subscriptions/crm/update_job.rb @@ -11,7 +11,7 @@ class UpdateJob < ApplicationJob retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10 retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(subscription:) + def perform(subscription) result = Integrations::Aggregator::Subscriptions::Crm::UpdateService.call(subscription:) result.raise_if_error! end diff --git a/app/jobs/integrations/hubspot/companies/deploy_properties_job.rb b/app/jobs/integrations/hubspot/companies/deploy_properties_job.rb index 50b73adc6f5..7bd630d757f 100644 --- a/app/jobs/integrations/hubspot/companies/deploy_properties_job.rb +++ b/app/jobs/integrations/hubspot/companies/deploy_properties_job.rb @@ -9,7 +9,7 @@ class DeployPropertiesJob < ApplicationJob retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(integration:) + def perform(integration) result = Integrations::Hubspot::Companies::DeployPropertiesService.call(integration:) result.raise_if_error! end diff --git a/app/jobs/integrations/hubspot/contacts/deploy_properties_job.rb b/app/jobs/integrations/hubspot/contacts/deploy_properties_job.rb index c0c5350b747..fe6078cca41 100644 --- a/app/jobs/integrations/hubspot/contacts/deploy_properties_job.rb +++ b/app/jobs/integrations/hubspot/contacts/deploy_properties_job.rb @@ -9,7 +9,7 @@ class DeployPropertiesJob < ApplicationJob retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(integration:) + def perform(integration) result = Integrations::Hubspot::Contacts::DeployPropertiesService.call(integration:) result.raise_if_error! end diff --git a/app/jobs/integrations/hubspot/invoices/deploy_object_job.rb b/app/jobs/integrations/hubspot/invoices/deploy_object_job.rb index a1d1570ddeb..6243aedf45c 100644 --- a/app/jobs/integrations/hubspot/invoices/deploy_object_job.rb +++ b/app/jobs/integrations/hubspot/invoices/deploy_object_job.rb @@ -9,7 +9,7 @@ class DeployObjectJob < ApplicationJob retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(integration:) + def perform(integration) result = Integrations::Hubspot::Invoices::DeployObjectService.call(integration:) result.raise_if_error! end diff --git a/app/jobs/integrations/hubspot/save_portal_id_job.rb b/app/jobs/integrations/hubspot/save_portal_id_job.rb index 4452ee1ee63..c33a65d4278 100644 --- a/app/jobs/integrations/hubspot/save_portal_id_job.rb +++ b/app/jobs/integrations/hubspot/save_portal_id_job.rb @@ -8,7 +8,7 @@ class SavePortalIdJob < ApplicationJob retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(integration:) + def perform(integration) result = Integrations::Hubspot::SavePortalIdService.call(integration:) result.raise_if_error! end diff --git a/app/jobs/integrations/hubspot/subscriptions/deploy_object_job.rb b/app/jobs/integrations/hubspot/subscriptions/deploy_object_job.rb index 03ddde11e07..2e5351c68b3 100644 --- a/app/jobs/integrations/hubspot/subscriptions/deploy_object_job.rb +++ b/app/jobs/integrations/hubspot/subscriptions/deploy_object_job.rb @@ -9,7 +9,7 @@ class DeployObjectJob < ApplicationJob retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100 - def perform(integration:) + def perform(integration) result = Integrations::Hubspot::Subscriptions::DeployObjectService.call(integration:) result.raise_if_error! end diff --git a/app/jobs/invoices/create_pay_in_advance_charge_job.rb b/app/jobs/invoices/create_pay_in_advance_charge_job.rb index 83971caf51b..f95e7a2362f 100644 --- a/app/jobs/invoices/create_pay_in_advance_charge_job.rb +++ b/app/jobs/invoices/create_pay_in_advance_charge_job.rb @@ -4,9 +4,11 @@ module Invoices class CreatePayInAdvanceChargeJob < ApplicationJob queue_as 'billing' + unique :until_executed, on_conflict: :log + retry_on Sequenced::SequenceError - def perform(charge:, event:, timestamp:, invoice: nil) + def perform(charge, event, timestamp, invoice = nil) result = Invoices::CreatePayInAdvanceChargeService.call(charge:, event:, timestamp:, invoice:) return if result.success? # NOTE: We don't want a dead job for failed invoice due to the tax reason. @@ -17,17 +19,19 @@ def perform(charge:, event:, timestamp:, invoice: nil) # NOTE: retry the job with the already created invoice in a previous failed attempt self.class.set(wait: 3.seconds).perform_later( - charge:, - event:, - timestamp:, - invoice: result.invoice + charge, + event, + timestamp, + result.invoice ) end def lock_key_arguments - args = arguments.first - event = Events::CommonFactory.new_instance(source: args[:event]) - [args[:charge], event.organization_id, event.external_subscription_id, event.transaction_id] + charge = arguments.first + arg_event = arguments.second + + event = Events::CommonFactory.new_instance(source: arg_event) + [charge, event.organization_id, event.external_subscription_id, event.transaction_id] end private diff --git a/app/services/events/pay_in_advance_service.rb b/app/services/events/pay_in_advance_service.rb index 3d5dc83693f..4eefa0974e9 100644 --- a/app/services/events/pay_in_advance_service.rb +++ b/app/services/events/pay_in_advance_service.rb @@ -22,11 +22,11 @@ def call end charges.where(invoiceable: false).find_each do |charge| - Fees::CreatePayInAdvanceJob.perform_later(charge:, event: event.as_json) + Fees::CreatePayInAdvanceJob.perform_later(charge, event.as_json) end charges.where(invoiceable: true).find_each do |charge| - Invoices::CreatePayInAdvanceChargeJob.perform_later(charge:, event: event.as_json, timestamp: event.timestamp) + Invoices::CreatePayInAdvanceChargeJob.perform_later(charge, event.as_json, event.timestamp) end result.event = event diff --git a/app/services/integrations/aggregator/invoices/create_service.rb b/app/services/integrations/aggregator/invoices/create_service.rb index 6ffd4aa4155..9e4cfe1863e 100644 --- a/app/services/integrations/aggregator/invoices/create_service.rb +++ b/app/services/integrations/aggregator/invoices/create_service.rb @@ -53,7 +53,7 @@ def call def call_async return result.not_found_failure!(resource: 'invoice') unless invoice - ::Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice:) + ::Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice) result.invoice_id = invoice.id result diff --git a/app/services/integrations/aggregator/payments/create_service.rb b/app/services/integrations/aggregator/payments/create_service.rb index fd5ab2391dd..a8f2334be1f 100644 --- a/app/services/integrations/aggregator/payments/create_service.rb +++ b/app/services/integrations/aggregator/payments/create_service.rb @@ -56,7 +56,7 @@ def call def call_async return result.not_found_failure!(resource: 'payment') unless payment - ::Integrations::Aggregator::Payments::CreateJob.perform_later(payment:) + ::Integrations::Aggregator::Payments::CreateJob.perform_later(payment) result.payment_id = payment.id result diff --git a/app/services/integrations/hubspot/create_service.rb b/app/services/integrations/hubspot/create_service.rb index 8b847e1d3e1..392b558ffcb 100644 --- a/app/services/integrations/hubspot/create_service.rb +++ b/app/services/integrations/hubspot/create_service.rb @@ -31,7 +31,7 @@ def call if integration.type == 'Integrations::HubspotIntegration' Integrations::Aggregator::SyncCustomObjectsAndPropertiesJob.perform_later(integration:) - Integrations::Hubspot::SavePortalIdJob.perform_later(integration:) + Integrations::Hubspot::SavePortalIdJob.perform_later(integration) end result.integration = integration diff --git a/app/services/invoices/add_on_service.rb b/app/services/invoices/add_on_service.rb index 0e99a7e35e4..4cc17761da8 100644 --- a/app/services/invoices/add_on_service.rb +++ b/app/services/invoices/add_on_service.rb @@ -37,11 +37,11 @@ def create GeneratePdfAndNotifyJob.perform_later(invoice: result.invoice, email: should_deliver_email?) if result.invoice.should_sync_invoice? - Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice: result.invoice) + Integrations::Aggregator::Invoices::CreateJob.perform_later(result.invoice) end if result.invoice.should_sync_crm_invoice? - Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice: result.invoice) + Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(result.invoice) end create_payment(result.invoice) diff --git a/app/services/invoices/advance_charges_service.rb b/app/services/invoices/advance_charges_service.rb index 51102c05903..e7220766142 100644 --- a/app/services/invoices/advance_charges_service.rb +++ b/app/services/invoices/advance_charges_service.rb @@ -23,8 +23,8 @@ def call if invoice && !invoice.closed? SendWebhookJob.perform_later('invoice.created', invoice) Invoices::GeneratePdfAndNotifyJob.perform_later(invoice:, email: false) - Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice:) if invoice.should_sync_invoice? - Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice:) if invoice.should_sync_crm_invoice? + Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice) if invoice.should_sync_invoice? + Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice) if invoice.should_sync_crm_invoice? Utils::SegmentTrack.invoice_created(invoice) end diff --git a/app/services/invoices/create_one_off_service.rb b/app/services/invoices/create_one_off_service.rb index 42d4f842ad5..c98755a11fd 100644 --- a/app/services/invoices/create_one_off_service.rb +++ b/app/services/invoices/create_one_off_service.rb @@ -44,8 +44,8 @@ def call Utils::SegmentTrack.invoice_created(invoice) SendWebhookJob.perform_later('invoice.one_off_created', invoice) GeneratePdfAndNotifyJob.perform_later(invoice:, email: should_deliver_email?) - Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice:) if invoice.should_sync_invoice? - Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice:) if invoice.should_sync_crm_invoice? + Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice) if invoice.should_sync_invoice? + Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice) if invoice.should_sync_crm_invoice? Invoices::Payments::CreateService.new(invoice).call end diff --git a/app/services/invoices/create_pay_in_advance_charge_service.rb b/app/services/invoices/create_pay_in_advance_charge_service.rb index 9f654b6e573..de8824f9628 100644 --- a/app/services/invoices/create_pay_in_advance_charge_service.rb +++ b/app/services/invoices/create_pay_in_advance_charge_service.rb @@ -51,8 +51,8 @@ def call Utils::SegmentTrack.invoice_created(invoice) deliver_webhooks GeneratePdfAndNotifyJob.perform_later(invoice:, email: should_deliver_email?) - Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice:) if invoice.should_sync_invoice? - Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice:) if invoice.should_sync_crm_invoice? + Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice) if invoice.should_sync_invoice? + Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice) if invoice.should_sync_crm_invoice? Invoices::Payments::CreateService.new(invoice).call end diff --git a/app/services/invoices/finalize_open_credit_service.rb b/app/services/invoices/finalize_open_credit_service.rb index d92280c2f65..579cf02a32b 100644 --- a/app/services/invoices/finalize_open_credit_service.rb +++ b/app/services/invoices/finalize_open_credit_service.rb @@ -22,8 +22,8 @@ def call SendWebhookJob.perform_later('invoice.paid_credit_added', result.invoice) GeneratePdfAndNotifyJob.perform_later(invoice:, email: should_deliver_email?) - Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice:) if invoice.should_sync_invoice? - Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice:) if invoice.should_sync_crm_invoice? + Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice) if invoice.should_sync_invoice? + Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice) if invoice.should_sync_crm_invoice? Utils::SegmentTrack.invoice_created(result.invoice) result diff --git a/app/services/invoices/paid_credit_service.rb b/app/services/invoices/paid_credit_service.rb index 7d52c11ebfa..15b932bdc1f 100644 --- a/app/services/invoices/paid_credit_service.rb +++ b/app/services/invoices/paid_credit_service.rb @@ -34,8 +34,8 @@ def call Utils::SegmentTrack.invoice_created(result.invoice) SendWebhookJob.perform_later('invoice.paid_credit_added', result.invoice) GeneratePdfAndNotifyJob.perform_later(invoice:, email: should_deliver_email?) - Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice:) if invoice.should_sync_invoice? - Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice:) if invoice.should_sync_crm_invoice? + Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice) if invoice.should_sync_invoice? + Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice) if invoice.should_sync_crm_invoice? end create_payment(result.invoice) diff --git a/app/services/invoices/payments/adyen_service.rb b/app/services/invoices/payments/adyen_service.rb index 075f300d067..86e5155a71f 100644 --- a/app/services/invoices/payments/adyen_service.rb +++ b/app/services/invoices/payments/adyen_service.rb @@ -47,7 +47,7 @@ def call invoice_payment_status = invoice_payment_status(payment.status) update_invoice_payment_status(payment_status: invoice_payment_status) - Integrations::Aggregator::Payments::CreateJob.perform_later(payment:) if payment.should_sync_payment? + Integrations::Aggregator::Payments::CreateJob.perform_later(payment) if payment.should_sync_payment? result.payment = payment result diff --git a/app/services/invoices/payments/gocardless_service.rb b/app/services/invoices/payments/gocardless_service.rb index 920588391f5..6c9f68dfbc4 100644 --- a/app/services/invoices/payments/gocardless_service.rb +++ b/app/services/invoices/payments/gocardless_service.rb @@ -56,7 +56,7 @@ def call invoice_payment_status = invoice_payment_status(payment.status) update_invoice_payment_status(payment_status: invoice_payment_status) - Integrations::Aggregator::Payments::CreateJob.perform_later(payment:) if payment.should_sync_payment? + Integrations::Aggregator::Payments::CreateJob.perform_later(payment) if payment.should_sync_payment? result.payment = payment result diff --git a/app/services/invoices/payments/stripe_service.rb b/app/services/invoices/payments/stripe_service.rb index 3a0ba0d2688..c075a5401e2 100644 --- a/app/services/invoices/payments/stripe_service.rb +++ b/app/services/invoices/payments/stripe_service.rb @@ -50,7 +50,7 @@ def call processing: payment.status == 'processing' ) - Integrations::Aggregator::Payments::CreateJob.perform_later(payment:) if payment.should_sync_payment? + Integrations::Aggregator::Payments::CreateJob.perform_later(payment) if payment.should_sync_payment? handle_requires_action(payment) if payment.status == 'requires_action' diff --git a/app/services/invoices/progressive_billing_service.rb b/app/services/invoices/progressive_billing_service.rb index 0296b9d402c..00c17726a84 100644 --- a/app/services/invoices/progressive_billing_service.rb +++ b/app/services/invoices/progressive_billing_service.rb @@ -48,8 +48,8 @@ def call Utils::SegmentTrack.invoice_created(invoice) SendWebhookJob.perform_later('invoice.created', invoice) Invoices::GeneratePdfAndNotifyJob.perform_later(invoice:, email: should_deliver_email?) - Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice:) if invoice.should_sync_invoice? - Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice:) if invoice.should_sync_crm_invoice? + Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice) if invoice.should_sync_invoice? + Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice) if invoice.should_sync_crm_invoice? Invoices::Payments::CreateService.call(invoice) result.invoice = invoice diff --git a/app/services/invoices/refresh_draft_and_finalize_service.rb b/app/services/invoices/refresh_draft_and_finalize_service.rb index b7e31bcc395..8b56fc0f328 100644 --- a/app/services/invoices/refresh_draft_and_finalize_service.rb +++ b/app/services/invoices/refresh_draft_and_finalize_service.rb @@ -33,8 +33,8 @@ def call unless invoice.closed? SendWebhookJob.perform_later('invoice.created', invoice) GeneratePdfAndNotifyJob.perform_later(invoice:, email: should_deliver_email?) - Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice:) if invoice.should_sync_invoice? - Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice:) if invoice.should_sync_crm_invoice? + Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice) if invoice.should_sync_invoice? + Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice) if invoice.should_sync_crm_invoice? Invoices::Payments::CreateService.new(invoice).call Utils::SegmentTrack.invoice_created(invoice) end diff --git a/app/services/invoices/retry_service.rb b/app/services/invoices/retry_service.rb index f76aaadd4af..b3a416bb72e 100644 --- a/app/services/invoices/retry_service.rb +++ b/app/services/invoices/retry_service.rb @@ -42,8 +42,8 @@ def call SendWebhookJob.perform_later('invoice.created', invoice) GeneratePdfAndNotifyJob.perform_later(invoice:, email: should_deliver_email?) - Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice:) if invoice.should_sync_invoice? - Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice:) if invoice.should_sync_crm_invoice? + Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice) if invoice.should_sync_invoice? + Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice) if invoice.should_sync_crm_invoice? Invoices::Payments::CreateService.new(invoice).call Utils::SegmentTrack.invoice_created(invoice) diff --git a/app/services/invoices/subscription_service.rb b/app/services/invoices/subscription_service.rb index f3bff70211e..bc7e1086635 100644 --- a/app/services/invoices/subscription_service.rb +++ b/app/services/invoices/subscription_service.rb @@ -67,8 +67,8 @@ def call unless invoice.closed? # we dont need to send the webhooks if the invoice was closed ( skip 0 invoice setting ) SendWebhookJob.perform_later('invoice.created', invoice) GeneratePdfAndNotifyJob.perform_later(invoice:, email: should_deliver_finalized_email?) - Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice:) if invoice.should_sync_invoice? - Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice:) if invoice.should_sync_crm_invoice? + Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice) if invoice.should_sync_invoice? + Integrations::Aggregator::Invoices::Crm::CreateJob.perform_later(invoice) if invoice.should_sync_crm_invoice? Invoices::Payments::CreateService.new(invoice).call Utils::SegmentTrack.invoice_created(invoice) end diff --git a/app/services/payment_requests/payments/adyen_service.rb b/app/services/payment_requests/payments/adyen_service.rb index c69a16721e0..0160013f388 100644 --- a/app/services/payment_requests/payments/adyen_service.rb +++ b/app/services/payment_requests/payments/adyen_service.rb @@ -52,7 +52,7 @@ def create update_payable_payment_status(payment_status: payable_payment_status) update_invoices_payment_status(payment_status: payable_payment_status) - Integrations::Aggregator::Payments::CreateJob.perform_later(payment:) if payment.should_sync_payment? + Integrations::Aggregator::Payments::CreateJob.perform_later(payment) if payment.should_sync_payment? result.payment = payment result diff --git a/app/services/payment_requests/payments/gocardless_service.rb b/app/services/payment_requests/payments/gocardless_service.rb index aa8d0717fbd..1a76fe52088 100644 --- a/app/services/payment_requests/payments/gocardless_service.rb +++ b/app/services/payment_requests/payments/gocardless_service.rb @@ -59,7 +59,7 @@ def create update_payable_payment_status(payment_status: payable_payment_status) update_invoices_payment_status(payment_status: payable_payment_status) - Integrations::Aggregator::Payments::CreateJob.perform_later(payment:) if payment.should_sync_payment? + Integrations::Aggregator::Payments::CreateJob.perform_later(payment) if payment.should_sync_payment? result.payment = payment result diff --git a/config/application.rb b/config/application.rb index 351d7e87a8c..9907d8200b6 100644 --- a/config/application.rb +++ b/config/application.rb @@ -42,3 +42,5 @@ class Application < Rails::Application config.active_support.cache_format_version = 7.1 end end + +require_relative "../lib/active_job/uniqueness/strategies/until_executed_patch" diff --git a/lib/active_job/uniqueness/strategies/until_executed_patch.rb b/lib/active_job/uniqueness/strategies/until_executed_patch.rb new file mode 100644 index 00000000000..b12b9097ae9 --- /dev/null +++ b/lib/active_job/uniqueness/strategies/until_executed_patch.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require "active_job/uniqueness/strategies/until_executed" + +module ActiveJob + module Uniqueness + module Strategies + class UntilExecutedPatch < UntilExecuted + def before_enqueue + return if lock(resource: lock_key, ttl: lock_ttl) + # We're retrying the job, so we don't need to lock again + return if job.executions > 0 + + handle_conflict(resource: lock_key, on_conflict: on_conflict) + abort_job + end + end + end + end +end diff --git a/spec/jobs/fees/create_pay_in_advance_job_spec.rb b/spec/jobs/fees/create_pay_in_advance_job_spec.rb index eb1a858f4cf..ec8f8931393 100644 --- a/spec/jobs/fees/create_pay_in_advance_job_spec.rb +++ b/spec/jobs/fees/create_pay_in_advance_job_spec.rb @@ -13,7 +13,7 @@ .with(charge:, event:, billing_at: nil) .and_return(result) - described_class.perform_now(charge:, event:) + described_class.perform_now(charge, event) expect(Fees::CreatePayInAdvanceService).to have_received(:call) end diff --git a/spec/jobs/integrations/aggregator/credit_notes/create_job_spec.rb b/spec/jobs/integrations/aggregator/credit_notes/create_job_spec.rb index e2b174b4da5..5212529c26d 100644 --- a/spec/jobs/integrations/aggregator/credit_notes/create_job_spec.rb +++ b/spec/jobs/integrations/aggregator/credit_notes/create_job_spec.rb @@ -15,7 +15,7 @@ end it 'calls the aggregator create credit_note service' do - described_class.perform_now(credit_note:) + described_class.perform_now(credit_note) aggregate_failures do expect(Integrations::Aggregator::CreditNotes::CreateService).to have_received(:new) diff --git a/spec/jobs/integrations/aggregator/invoices/create_job_spec.rb b/spec/jobs/integrations/aggregator/invoices/create_job_spec.rb index 5bc66f76ebc..77a5828959e 100644 --- a/spec/jobs/integrations/aggregator/invoices/create_job_spec.rb +++ b/spec/jobs/integrations/aggregator/invoices/create_job_spec.rb @@ -15,7 +15,7 @@ end it 'calls the aggregator create invoice service' do - described_class.perform_now(invoice:) + described_class.perform_now(invoice) aggregate_failures do expect(Integrations::Aggregator::Invoices::CreateService).to have_received(:new) diff --git a/spec/jobs/integrations/aggregator/invoices/crm/create_customer_association_job_spec.rb b/spec/jobs/integrations/aggregator/invoices/crm/create_customer_association_job_spec.rb index 544dea6ffd6..85bb39c1047 100644 --- a/spec/jobs/integrations/aggregator/invoices/crm/create_customer_association_job_spec.rb +++ b/spec/jobs/integrations/aggregator/invoices/crm/create_customer_association_job_spec.rb @@ -16,7 +16,7 @@ end it 'calls the aggregator create invoice crm service' do - described_class.perform_now(invoice:) + described_class.perform_now(invoice) aggregate_failures do expect(Integrations::Aggregator::Invoices::Crm::CreateCustomerAssociationService).to have_received(:new) diff --git a/spec/jobs/integrations/aggregator/invoices/crm/create_job_spec.rb b/spec/jobs/integrations/aggregator/invoices/crm/create_job_spec.rb index 717866b6854..12661b40296 100644 --- a/spec/jobs/integrations/aggregator/invoices/crm/create_job_spec.rb +++ b/spec/jobs/integrations/aggregator/invoices/crm/create_job_spec.rb @@ -21,13 +21,13 @@ end it 'raises an error' do - expect { create_job.perform_now(invoice:) }.to raise_error(StandardError) + expect { create_job.perform_now(invoice) }.to raise_error(StandardError) end end context 'when the service call is successful' do it 'calls the aggregator create invoice crm service' do - described_class.perform_now(invoice:) + described_class.perform_now(invoice) aggregate_failures do expect(Integrations::Aggregator::Invoices::Crm::CreateService).to have_received(:new) @@ -37,8 +37,8 @@ it 'enqueues the aggregator create customer association invoice job' do expect do - described_class.perform_now(invoice:) - end.to have_enqueued_job(Integrations::Aggregator::Invoices::Crm::CreateCustomerAssociationJob).with(invoice:) + described_class.perform_now(invoice) + end.to have_enqueued_job(Integrations::Aggregator::Invoices::Crm::CreateCustomerAssociationJob).with(invoice) end end end diff --git a/spec/jobs/integrations/aggregator/invoices/crm/update_job_spec.rb b/spec/jobs/integrations/aggregator/invoices/crm/update_job_spec.rb index 9df61f34494..bfe3cd06400 100644 --- a/spec/jobs/integrations/aggregator/invoices/crm/update_job_spec.rb +++ b/spec/jobs/integrations/aggregator/invoices/crm/update_job_spec.rb @@ -15,7 +15,7 @@ end it 'calls the aggregator create invoice crm service' do - described_class.perform_now(invoice:) + described_class.perform_now(invoice) aggregate_failures do expect(Integrations::Aggregator::Invoices::Crm::UpdateService).to have_received(:new) diff --git a/spec/jobs/integrations/aggregator/payments/create_job_spec.rb b/spec/jobs/integrations/aggregator/payments/create_job_spec.rb index c1b9b197eb5..3646e00aa3e 100644 --- a/spec/jobs/integrations/aggregator/payments/create_job_spec.rb +++ b/spec/jobs/integrations/aggregator/payments/create_job_spec.rb @@ -15,7 +15,7 @@ end it 'calls the aggregator create payment service' do - described_class.perform_now(payment:) + described_class.perform_now(payment) aggregate_failures do expect(Integrations::Aggregator::Payments::CreateService).to have_received(:new) diff --git a/spec/jobs/integrations/aggregator/subscriptions/crm/create_customer_association_job_spec.rb b/spec/jobs/integrations/aggregator/subscriptions/crm/create_customer_association_job_spec.rb index 4207724a885..f630130ff46 100644 --- a/spec/jobs/integrations/aggregator/subscriptions/crm/create_customer_association_job_spec.rb +++ b/spec/jobs/integrations/aggregator/subscriptions/crm/create_customer_association_job_spec.rb @@ -16,7 +16,7 @@ end it 'calls the aggregator create subscription crm service' do - described_class.perform_now(subscription:) + described_class.perform_now(subscription) aggregate_failures do expect(Integrations::Aggregator::Subscriptions::Crm::CreateCustomerAssociationService).to have_received(:new) diff --git a/spec/jobs/integrations/aggregator/subscriptions/crm/create_job_spec.rb b/spec/jobs/integrations/aggregator/subscriptions/crm/create_job_spec.rb index c66c8091c61..8d8b7a854fc 100644 --- a/spec/jobs/integrations/aggregator/subscriptions/crm/create_job_spec.rb +++ b/spec/jobs/integrations/aggregator/subscriptions/crm/create_job_spec.rb @@ -21,13 +21,13 @@ end it 'raises an error' do - expect { create_job.perform_now(subscription:) }.to raise_error(StandardError) + expect { create_job.perform_now(subscription) }.to raise_error(StandardError) end end context 'when the service call is successful' do it 'calls the aggregator create subscription crm service' do - described_class.perform_now(subscription:) + described_class.perform_now(subscription) aggregate_failures do expect(Integrations::Aggregator::Subscriptions::Crm::CreateService).to have_received(:new) @@ -37,8 +37,9 @@ it 'enqueues the aggregator create customer association subscription job' do expect do - described_class.perform_now(subscription:) - end.to have_enqueued_job(Integrations::Aggregator::Subscriptions::Crm::CreateCustomerAssociationJob).with(subscription:) + described_class.perform_now(subscription) + end.to have_enqueued_job(Integrations::Aggregator::Subscriptions::Crm::CreateCustomerAssociationJob) + .with(subscription) end end end diff --git a/spec/jobs/integrations/aggregator/subscriptions/crm/update_job_spec.rb b/spec/jobs/integrations/aggregator/subscriptions/crm/update_job_spec.rb index 0dffad555d2..a0434f46ba8 100644 --- a/spec/jobs/integrations/aggregator/subscriptions/crm/update_job_spec.rb +++ b/spec/jobs/integrations/aggregator/subscriptions/crm/update_job_spec.rb @@ -15,7 +15,7 @@ end it 'calls the aggregator create subscription crm service' do - described_class.perform_now(subscription:) + described_class.perform_now(subscription) aggregate_failures do expect(Integrations::Aggregator::Subscriptions::Crm::UpdateService).to have_received(:new) diff --git a/spec/jobs/integrations/hubspot/companies/deploy_properties_job_spec.rb b/spec/jobs/integrations/hubspot/companies/deploy_properties_job_spec.rb index 9d78047a8a1..8337c50a21c 100644 --- a/spec/jobs/integrations/hubspot/companies/deploy_properties_job_spec.rb +++ b/spec/jobs/integrations/hubspot/companies/deploy_properties_job_spec.rb @@ -16,7 +16,7 @@ end it 'calls the DeployPropertiesService to sync companies custom properties' do - deploy_properties_job.perform_now(integration:) + deploy_properties_job.perform_now(integration) expect(Integrations::Hubspot::Companies::DeployPropertiesService).to have_received(:new) expect(deploy_company_service).to have_received(:call) end diff --git a/spec/jobs/integrations/hubspot/contacts/deploy_properties_job_spec.rb b/spec/jobs/integrations/hubspot/contacts/deploy_properties_job_spec.rb index 49ccddffdf8..04234df3ba3 100644 --- a/spec/jobs/integrations/hubspot/contacts/deploy_properties_job_spec.rb +++ b/spec/jobs/integrations/hubspot/contacts/deploy_properties_job_spec.rb @@ -16,7 +16,7 @@ end it 'calls the DeployPropertiesService to sync contacts custom properties' do - deploy_properties_job.perform_now(integration:) + deploy_properties_job.perform_now(integration) expect(Integrations::Hubspot::Contacts::DeployPropertiesService).to have_received(:new) expect(deploy_contact_service).to have_received(:call) diff --git a/spec/jobs/integrations/hubspot/invoices/deploy_object_job_spec.rb b/spec/jobs/integrations/hubspot/invoices/deploy_object_job_spec.rb index 7e738f3b3b0..18b3a56061f 100644 --- a/spec/jobs/integrations/hubspot/invoices/deploy_object_job_spec.rb +++ b/spec/jobs/integrations/hubspot/invoices/deploy_object_job_spec.rb @@ -16,7 +16,7 @@ end it 'calls the DeployObjectService to deploy invoice custom object' do - deploy_object_job.perform_now(integration:) + deploy_object_job.perform_now(integration) expect(Integrations::Hubspot::Invoices::DeployObjectService).to have_received(:new) expect(deploy_object_service).to have_received(:call) diff --git a/spec/jobs/integrations/hubspot/save_portal_id_job_spec.rb b/spec/jobs/integrations/hubspot/save_portal_id_job_spec.rb index 36a8c6698b3..f5f3e41a0a6 100644 --- a/spec/jobs/integrations/hubspot/save_portal_id_job_spec.rb +++ b/spec/jobs/integrations/hubspot/save_portal_id_job_spec.rb @@ -16,7 +16,7 @@ end it 'saves portal id to the integration' do - described_class.perform_now(integration:) + described_class.perform_now(integration) expect(Integrations::Hubspot::SavePortalIdService).to have_received(:new) expect(service).to have_received(:call) diff --git a/spec/jobs/integrations/hubspot/subscriptions/deploy_object_job_spec.rb b/spec/jobs/integrations/hubspot/subscriptions/deploy_object_job_spec.rb index e5ab95d0353..558ebacae44 100644 --- a/spec/jobs/integrations/hubspot/subscriptions/deploy_object_job_spec.rb +++ b/spec/jobs/integrations/hubspot/subscriptions/deploy_object_job_spec.rb @@ -16,7 +16,7 @@ end it 'calls the DeployObjectService to deploy subscription custom object' do - deploy_object_job.perform_now(integration:) + deploy_object_job.perform_now(integration) expect(Integrations::Hubspot::Subscriptions::DeployObjectService).to have_received(:new) expect(deploy_object_service).to have_received(:call) diff --git a/spec/jobs/invoices/create_pay_in_advance_charge_job_spec.rb b/spec/jobs/invoices/create_pay_in_advance_charge_job_spec.rb index 07968a4f26e..258064f69c0 100644 --- a/spec/jobs/invoices/create_pay_in_advance_charge_job_spec.rb +++ b/spec/jobs/invoices/create_pay_in_advance_charge_job_spec.rb @@ -20,7 +20,7 @@ end it 'calls the create pay in advance charge service' do - described_class.perform_now(charge:, event:, timestamp:) + described_class.perform_now(charge, event, timestamp) expect(Invoices::CreatePayInAdvanceChargeService).to have_received(:new) expect(invoice_service).to have_received(:call) @@ -33,7 +33,7 @@ it 'raises an error' do expect do - described_class.perform_now(charge:, event:, timestamp:) + described_class.perform_now(charge, event, timestamp) end.to raise_error(BaseService::FailedResult) expect(Invoices::CreatePayInAdvanceChargeService).to have_received(:new) @@ -45,7 +45,7 @@ it 'raises an error' do expect do - described_class.perform_now(charge:, event:, timestamp:, invoice:) + described_class.perform_now(charge, event, timestamp, invoice) end.to raise_error(BaseService::FailedResult) expect(Invoices::CreatePayInAdvanceChargeService).to have_received(:new) @@ -59,13 +59,13 @@ before { result.invoice = result_invoice } it 'retries the job with the invoice' do - described_class.perform_now(charge:, event:, timestamp:) + described_class.perform_now(charge, event, timestamp) expect(Invoices::CreatePayInAdvanceChargeService).to have_received(:new) expect(invoice_service).to have_received(:call) expect(described_class).to have_been_enqueued - .with(charge:, event:, timestamp:, invoice: result_invoice) + .with(charge, event, timestamp, result_invoice) end end @@ -76,7 +76,7 @@ it 'raises an error' do expect do - described_class.perform_now(charge:, event:, timestamp:) + described_class.perform_now(charge, event, timestamp) end.to raise_error(BaseService::FailedResult) expect(Invoices::CreatePayInAdvanceChargeService).to have_received(:new) diff --git a/spec/services/integrations/hubspot/create_service_spec.rb b/spec/services/integrations/hubspot/create_service_spec.rb index c08eda9cb06..0c945e31422 100644 --- a/spec/services/integrations/hubspot/create_service_spec.rb +++ b/spec/services/integrations/hubspot/create_service_spec.rb @@ -86,7 +86,7 @@ integration = Integrations::HubspotIntegration.order(:created_at).last expect(Integrations::Aggregator::SyncCustomObjectsAndPropertiesJob).to have_received(:perform_later).with(integration:) - expect(Integrations::Hubspot::SavePortalIdJob).to have_received(:perform_later).with(integration:) + expect(Integrations::Hubspot::SavePortalIdJob).to have_received(:perform_later).with(integration) end end diff --git a/spec/services/invoices/advance_charges_service_spec.rb b/spec/services/invoices/advance_charges_service_spec.rb index 2e3d5a3e176..2d599f5fde3 100644 --- a/spec/services/invoices/advance_charges_service_spec.rb +++ b/spec/services/invoices/advance_charges_service_spec.rb @@ -123,7 +123,7 @@ def fee_boundaries it 'creates invoices' do result = invoice_service.call - expect(Integrations::Aggregator::Invoices::CreateJob).to have_been_enqueued.with(invoice: result.invoice) + expect(Integrations::Aggregator::Invoices::CreateJob).to have_been_enqueued.with(result.invoice) end end end diff --git a/spec/services/invoices/finalize_open_credit_service_spec.rb b/spec/services/invoices/finalize_open_credit_service_spec.rb index 5dafe732804..407cb29a235 100644 --- a/spec/services/invoices/finalize_open_credit_service_spec.rb +++ b/spec/services/invoices/finalize_open_credit_service_spec.rb @@ -24,7 +24,7 @@ expect(SendWebhookJob).to have_been_enqueued.with('invoice.paid_credit_added', result.invoice) expect(Invoices::GeneratePdfAndNotifyJob).to have_been_enqueued.with(invoice: result.invoice, email: false) - expect(Integrations::Aggregator::Invoices::CreateJob).to have_been_enqueued.with(invoice: result.invoice) + expect(Integrations::Aggregator::Invoices::CreateJob).to have_been_enqueued.with(result.invoice) expect(SegmentTrackJob).to have_been_enqueued.with(membership_id: anything, event: 'invoice_created', properties: { organization_id: result.invoice.organization.id, invoice_id: result.invoice.id,