Skip to content

Commit

Permalink
fix(integrations): Fix creating a deleted customer (#2265)
Browse files Browse the repository at this point in the history
## Context

We were getting a lot of dead jobs when trying to sync a deleted
customer to nango (netsuite).

## Description

This PR fixes the issue by not trying to sync a non-existent (deleted)
customer.
  • Loading branch information
ivannovosad committed Jul 10, 2024
1 parent bc7b5af commit 7cf858a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(integration_customers:, customer:, new_customer:)
end

def call
return if integration_customers.nil?
return if integration_customers.nil? || customer.nil?

sanitize_integration_customers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@
end
end

context 'without customer' do
let(:integration_code) { integration.code }
let(:sync_with_provider) { true }
let(:external_customer_id) { nil }
let(:new_customer) { true }
let(:customer) { nil }

it 'does not call create job' do
expect { service_call }.not_to have_enqueued_job(IntegrationCustomers::CreateJob)
end

it 'does not call update job' do
expect { service_call }.not_to have_enqueued_job(IntegrationCustomers::UpdateJob)
end
end

context 'without external fields set' do
let(:integration_code) { integration.code }
let(:sync_with_provider) { false }
Expand Down

0 comments on commit 7cf858a

Please sign in to comment.