diff --git a/app/services/integration_customers/create_or_update_service.rb b/app/services/integration_customers/create_or_update_service.rb index 41cd56f9f83..fcbdfd8698f 100644 --- a/app/services/integration_customers/create_or_update_service.rb +++ b/app/services/integration_customers/create_or_update_service.rb @@ -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 diff --git a/spec/services/integration_customers/create_or_update_service_spec.rb b/spec/services/integration_customers/create_or_update_service_spec.rb index bd9d30826b2..678c54f6d0b 100644 --- a/spec/services/integration_customers/create_or_update_service_spec.rb +++ b/spec/services/integration_customers/create_or_update_service_spec.rb @@ -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 }