From 1abe76279c46e1b3c782e1dac584ce42da75baed Mon Sep 17 00:00:00 2001 From: Miguel Pinto Date: Wed, 2 Oct 2024 11:45:38 +0100 Subject: [PATCH] feat: added invoices service --- .../properties/deploy_contacts_service.rb | 1 + .../properties/deploy_contacts_service_spec.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/services/integrations/hubspot/properties/deploy_contacts_service.rb b/app/services/integrations/hubspot/properties/deploy_contacts_service.rb index 06d49153e01..a64ad77face 100644 --- a/app/services/integrations/hubspot/properties/deploy_contacts_service.rb +++ b/app/services/integrations/hubspot/properties/deploy_contacts_service.rb @@ -12,6 +12,7 @@ def action_path def call return unless integration.type == 'Integrations::HubspotIntegration' + return result if integration.contacts_properties_version == VERSION response = http_client.post_with_response(payload, headers) if response.success? diff --git a/spec/services/integrations/hubspot/properties/deploy_contacts_service_spec.rb b/spec/services/integrations/hubspot/properties/deploy_contacts_service_spec.rb index 3aec7c647bf..d4f4e8806bc 100644 --- a/spec/services/integrations/hubspot/properties/deploy_contacts_service_spec.rb +++ b/spec/services/integrations/hubspot/properties/deploy_contacts_service_spec.rb @@ -35,6 +35,23 @@ end end + context 'when contacts_properties_version is already up-to-date' do + before do + integration.contacts_properties_version = described_class::VERSION + integration.save! + end + + it 'does not make an API call and keeps the version unchanged' do + deploy_contacts_service.call + + aggregate_failures do + expect(LagoHttpClient::Client).not_to have_received(:new) + expect(http_client).not_to have_received(:post_with_response) + expect(integration.reload.contacts_properties_version).to eq(described_class::VERSION) + end + end + end + context 'when the API call fails' do let(:response) { instance_double('Response', success?: false) }