Browse Source

Maintenance: Port Clearbit integration test to RSpec

Mantas Masalskis 2 years ago
parent
commit
529b5275db

+ 0 - 8
.gitlab/ci/test/integration/other.yml

@@ -1,8 +0,0 @@
-"minitest:integration:other":
-  extends:
-    - .template_integration
-  allow_failure: true
-  script:
-    - !reference [.scripts, zammad_db_unseeded]
-    - echo "Clearbit test..."
-    - bundle exec rails test test/integration/clearbit_test.rb

+ 5 - 1
spec/factories/object_manager_attribute.rb

@@ -41,13 +41,17 @@ FactoryBot.define do
   end
 
   factory :object_manager_attribute_text, parent: :object_manager_attribute do
+    transient do
+      data_option_maxlength { 200 }
+    end
+
     default { '' }
 
     data_type { 'input' }
     data_option do
       {
         'type'      => 'text',
-        'maxlength' => 200,
+        'maxlength' => data_option_maxlength,
         'null'      => true,
         'translate' => false,
         'default'   => default,

+ 425 - 0
spec/integration/clearbit_spec.rb

@@ -0,0 +1,425 @@
+# Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
+
+require 'rails_helper'
+RSpec.describe 'Clearbit', aggregate_failures: true, current_user_id: 1, integration: true, performs_jobs: true, required_envs: %w[CLEARBIT_CI_API_KEY] do
+  let(:clearbit_config_organization_shared) { false }
+  let(:clearbit_config_user_bio)            { 'user.note' }
+  let(:clearbit_config_company_bio)         { 'organization.note' }
+  let(:clearbit_config_user_familyname)     { 'user.lastname' }
+
+  before do
+    Setting.set('clearbit_integration', true)
+    Setting.set('clearbit_config', {
+                  api_key:                 ENV['CLEARBIT_CI_API_KEY'],
+                  organization_autocreate: true,
+                  organization_shared:     clearbit_config_organization_shared,
+                  user_sync:               {
+                    'person.name.givenName'  => 'user.firstname',
+                    'person.name.familyName' => clearbit_config_user_familyname,
+                    'person.email'           => 'user.email',
+                    'person.bio'             => clearbit_config_user_bio,
+                    'company.url'            => 'user.web',
+                    'person.site'            => 'user.web',
+                    'company.location'       => 'user.address',
+                    'person.location'        => 'user.address',
+                  },
+                  organization_sync:       {
+                    'company.legalName'   => 'organization.name',
+                    'company.name'        => 'organization.name',
+                    'company.description' => clearbit_config_company_bio,
+                  },
+                })
+  end
+
+  describe 'case 1 - person + company (demo data set)' do
+    let(:customer) do
+      User.create!(
+        firstname: '',
+        lastname:  'Should be still there',
+        email:     'alex@alexmaccaw.com',
+        note:      '',
+      )
+    end
+
+    before do
+      customer
+
+      perform_enqueued_jobs commit_transaction: true
+
+      customer.reload
+    end
+
+    it 'enriches the customer' do
+      expect(ExternalSync).to be_exist(source: 'clearbit', object: 'User', o_id: customer.id)
+
+      expect(customer).to have_attributes(
+        firstname: 'Should',
+        lastname:  'be still there',
+        note:      'O\'Reilly author, software engineer &amp; traveller. Founder of <a href="https://clearbit.com" rel="nofollow noreferrer noopener" target="_blank">https://clearbit.com</a>',
+        address:   '1455 Market Street, San Francisco, CA 94103, USA',
+      )
+    end
+
+    it 'creates organization with enriched data' do
+      expect(ExternalSync).to be_exist(source: 'clearbit', object: 'Organization', o_id: customer.organization.id)
+
+      expect(customer.organization).to have_attributes(
+        name:   'Uber, Inc.',
+        shared: false,
+        note:   'Uber is a mobile app connecting passengers with drivers for hire.'
+      )
+    end
+
+    context 'with organization shared set to true' do
+      let(:clearbit_config_organization_shared) { true }
+
+      it 'creates organization with enriched data' do
+        expect(customer.organization).to have_attributes(
+          name:   'Uber, Inc.',
+          shared: true,
+        )
+      end
+    end
+
+    context 'with non existing note field' do
+      let(:clearbit_config_user_bio)    { 'user.note_not_existing' }
+      let(:clearbit_config_company_bio) { 'organization.note_not_existing' }
+
+      it 'syncs the rest of user fields' do
+        expect(ExternalSync).to be_exist(source: 'clearbit', object: 'User', o_id: customer.id)
+
+        expect(customer).to have_attributes(
+          firstname: 'Should',
+          lastname:  'be still there',
+          note:      '',
+        )
+      end
+
+      it 'syncs the rest of organization fields' do
+        expect(ExternalSync).to be_exist(source: 'clearbit', object: 'Organization', o_id: customer.organization.id)
+
+        expect(customer.organization).to have_attributes(
+          name: 'Uber, Inc.',
+          note: ''
+        )
+      end
+    end
+  end
+
+  describe 'case 2 - person + company' do
+    let(:customer) do
+      User.create!(
+        firstname: '',
+        lastname:  '',
+        email:     'me@example.com',
+        note:      '',
+      )
+    end
+
+    before do
+      customer
+
+      perform_enqueued_jobs commit_transaction: true
+
+      customer.reload
+    end
+
+    it 'enriches the customer' do
+      expect(ExternalSync).to be_exist(source: 'clearbit', object: 'User', o_id: customer.id)
+
+      expect(customer).to have_attributes(
+        firstname: 'Martin',
+        lastname:  'Edenhofer',
+        note:      "Open Source professional and geek. Also known as OTRS inventor. ;)\r\nEntrepreneur and Advisor for open source people in need.",
+        address:   'Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany',
+      )
+    end
+
+    it 'creates organization with enriched data' do
+      expect(ExternalSync).to be_exist(source: 'clearbit', object: 'Organization', o_id: customer.organization.id)
+
+      expect(customer.organization).to have_attributes(
+        name: 'OTRS',
+        note: 'OTRS is an Open Source helpdesk software and an IT Service Management software free of licence costs. Improve your Customer Service Management with OTRS.'
+      )
+    end
+
+    context 'when email changes' do
+      before do
+        customer.update!(
+          email: 'me2@example.com',
+        )
+
+        Enrichment::Clearbit::User.new(customer).synced?
+
+        perform_enqueued_jobs commit_transaction: true
+      end
+
+      it 'Update with another email data' do
+        expect(customer.reload).to have_attributes(
+          firstname: 'Martini',
+          lastname:  'Edenhofer',
+          address:   'Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany',
+        )
+      end
+    end
+
+    context 'when updated locally' do
+      before do
+        customer.update!(
+          firstname: 'Martini',
+          note:      'changed by my self',
+        )
+
+        Enrichment::Clearbit::User.new(customer).synced?
+
+        perform_enqueued_jobs commit_transaction: true
+      end
+
+      it 'stores locally updated value' do
+        expect(customer.reload).to have_attributes(
+          firstname: 'Martini',
+          lastname:  'Edenhofer',
+          note:      'changed by my self',
+          address:   'Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany',
+        )
+      end
+
+      context 'when set to empty value' do
+        before do
+          customer.update!(
+            firstname: '',
+            note:      'changed by my self again',
+          )
+
+          Enrichment::Clearbit::User.new(customer).synced?
+
+          perform_enqueued_jobs commit_transaction: true
+        end
+
+        it 'reverts to enriched data' do
+          expect(customer.reload).to have_attributes(
+            firstname: 'Martin',
+            lastname:  'Edenhofer',
+            note:      'changed by my self again',
+            address:   'Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany',
+          )
+        end
+      end
+    end
+  end
+
+  describe 'case 3 - no person' do
+    let(:customer) do
+      User.create!(
+        firstname: '',
+        lastname:  '',
+        email:     'testing3@znuny.com',
+        note:      '',
+      )
+    end
+
+    before do
+      customer
+
+      perform_enqueued_jobs commit_transaction: true
+
+      customer.reload
+    end
+
+    it 'does not enrich the customer' do
+      expect(ExternalSync).not_to be_exist(source: 'clearbit', object: 'User', o_id: customer.id)
+
+      expect(customer.reload).to have_attributes(
+        firstname: '',
+        lastname:  '',
+        note:      '',
+        web:       'http://znuny.com',
+        address:   'Marienstraße 11, 10117 Berlin, Germany',
+      )
+    end
+
+    it 'creates organization with enriched data' do
+      expect(ExternalSync).to be_exist(source: 'clearbit', object: 'Organization', o_id: customer.organization.id)
+
+      expect(customer.organization).to have_attributes(
+        name: 'Znuny / ES for OTRS',
+        note: 'OTRS Support, Consulting, Development, Training and Customizing - Znuny GmbH'
+      )
+    end
+  end
+
+  describe 'case 4 - person with organization but organization is already assigned (own created)' do
+    let(:customer) do
+      User.create!(
+        firstname:       '',
+        lastname:        '',
+        email:           'testing4@znuny.com',
+        note:            '',
+        organization_id: 1,
+      )
+    end
+
+    before do
+      customer
+
+      perform_enqueued_jobs commit_transaction: true
+
+      customer.reload
+    end
+
+    it 'enriches the customer' do
+      expect(customer).to have_attributes(
+        firstname: 'Fred',
+        lastname:  'Jupiter',
+        note:      'some_fred_bio',
+        web:       'http://fred.znuny.com',
+        address:   'Marienstraße 11, 10117 Berlin, Germany',
+      )
+    end
+
+    it 'does not create organization with enriched data' do
+      expect(customer.organization).to be_present
+
+      expect(Organization).not_to be_exist(name: 'ZnunyOfFred')
+    end
+  end
+
+  describe 'case 5 - person with organization but organization is already assigned (own created)' do
+    let(:customer) do
+      User.create!(
+        firstname:       '',
+        lastname:        '',
+        email:           'testing5@znuny.com',
+        note:            '',
+        created_by_id:   1,
+        updated_by_id:   1,
+        organization_id: another_clearbit_organization.id,
+      )
+    end
+
+    let(:another_clearbit_organization) do
+      user = User.create!(email: 'testing3@znuny.com')
+
+      perform_enqueued_jobs commit_transaction: true
+
+      user.reload.organization
+    end
+
+    before do
+      customer
+
+      perform_enqueued_jobs commit_transaction: true
+
+      customer.reload
+    end
+
+    it 'enriches the customer' do
+      expect(ExternalSync).to be_exist(source: 'clearbit', object: 'User', o_id: customer.id)
+
+      expect(customer).to have_attributes(
+        firstname: 'Alex',
+        lastname:  'Dont',
+        note:      'some_bio_alex',
+        web:       'http://znuny.com',
+        address:   'Marienstraße 11, 10117 Berlin, Germany',
+      )
+    end
+
+    it 'updates existing organization with enriched data' do
+      expect(customer.organization).to have_attributes(
+        name: 'Znuny GmbH',
+        note: 'OTRS Support, Consulting, Development, Training and Customizing - Znuny GmbH'
+      )
+
+      expect(another_clearbit_organization.id).to eq customer.organization.id
+    end
+  end
+
+  describe 'case 6 - no person / real api call' do
+    let(:customer) do
+      User.create!(
+        firstname: '',
+        lastname:  '',
+        email:     'testing6@clearbit.com',
+        note:      '',
+      )
+    end
+
+    before do
+      customer
+
+      VCR.configure do |c|
+        c.ignore_hosts 'person-stream.clearbit.com'
+      end
+
+      perform_enqueued_jobs commit_transaction: true
+
+      VCR.configure do |c|
+        c.unignore_hosts 'person-stream.clearbit.com'
+      end
+
+      customer.reload
+    end
+
+    it 'does not enrich the customer' do
+      expect(ExternalSync).not_to be_exist(source: 'clearbit', object: 'User', o_id: customer.id)
+
+      expect(customer).to have_attributes(
+        firstname: '',
+        lastname:  '',
+        note:      '',
+        web:       '',
+        address:   be_in(
+          [
+            'San Francisco, CA, USA',
+            'San Francisco, CA 94103, USA',
+            '90 Sheridan St, San Francisco, CA 94103, USA',
+            '90 Sheridan, San Francisco, CA 94103, USA',
+            '3030 16th St, San Francisco, CA 94103, USA',
+            '548 Market St, San Francisco, CA 94104, USA',
+          ]
+        )
+      )
+    end
+
+    it 'creates organization with enriched data' do
+      expect(ExternalSync).to be_exist(source: 'clearbit', object: 'Organization', o_id: customer.organization.id)
+
+      expect(customer.organization).to have_attributes(
+        name: start_with('APIHub Inc'),
+        note: 'The Clearbit Data Activation Platform helps B2B teams understand customers, identify prospects, &amp; personalize interactions with real-time intelligence.'
+      )
+    end
+  end
+
+  context 'when using custom attribute', db_strategy: :reset do
+    let(:clearbit_config_user_familyname) { 'user.test_input' }
+
+    let(:customer) do
+      User.create!(
+        firstname: '',
+        lastname:  '',
+        email:     'testing6@znuny.com',
+        note:      '',
+      )
+    end
+
+    before do
+      create(:object_manager_attribute_text, object_name: 'User', name: 'test_input', data_option_maxlength: 2)
+      ObjectManager::Attribute.migration_execute
+
+      customer
+
+      perform_enqueued_jobs commit_transaction: true
+
+      customer.reload
+    end
+
+    it 'Limits enrichment data to database limit' do
+      expect(ExternalSync).to be_exist(source: 'clearbit', object: 'User', o_id: customer.id)
+
+      expect(customer.test_input).to eq 'Sm'
+    end
+  end
+end

+ 0 - 421
test/integration/clearbit_test.rb

@@ -1,421 +0,0 @@
-# Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
-
-require 'test_helper'
-
-class ClearbitTest < ActiveSupport::TestCase
-  include BackgroundJobsHelper
-
-  # check
-  test 'base' do
-    if !ENV['CLEARBIT_CI_API_KEY']
-      raise "ERROR: Need CLEARBIT_CI_API_KEY - hint CLEARBIT_CI_API_KEY='abc...'"
-    end
-
-    # set system mode to done / to activate
-    Setting.set('system_init_done', true)
-
-    Setting.set('clearbit_integration', true)
-    Setting.set('clearbit_config', {
-                  api_key:                 ENV['CLEARBIT_CI_API_KEY'],
-                  organization_autocreate: true,
-                  organization_shared:     false,
-                  user_sync:               {
-                    'person.name.givenName'  => 'user.firstname',
-                    'person.name.familyName' => 'user.lastname',
-                    'person.email'           => 'user.email',
-                    'person.bio'             => 'user.note',
-                    'company.url'            => 'user.web',
-                    'person.site'            => 'user.web',
-                    'company.location'       => 'user.address',
-                    'person.location'        => 'user.address',
-                    # 'person.timeZone' => 'user.preferences[:timezone]',
-                    # 'person.gender' => 'user.preferences[:gender]',
-                  },
-                  organization_sync:       {
-                    'company.legalName'   => 'organization.name',
-                    'company.name'        => 'organization.name',
-                    'company.description' => 'organization.note',
-                  },
-                })
-
-    # case 1 - person + company (demo data set)
-    customer1 = User.create!(
-      firstname:     '',
-      lastname:      'Should be still there',
-      email:         'alex@alexmaccaw.com',
-      note:          '',
-      updated_by_id: 1,
-      created_by_id: 1,
-    )
-    assert(customer1)
-
-    perform_enqueued_jobs commit_transaction: true
-
-    assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer1.id))
-
-    customer1.reload
-
-    assert_equal('Should', customer1.firstname)
-    assert_equal('be still there', customer1.lastname)
-    assert_equal('O\'Reilly author, software engineer &amp; traveller. Founder of <a href="https://clearbit.com" rel="nofollow noreferrer noopener" target="_blank">https://clearbit.com</a>', customer1.note)
-    assert_equal('1455 Market Street, San Francisco, CA 94103, USA', customer1.address)
-
-    organization1 = Organization.find_by(name: 'Uber, Inc.')
-    assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization1.id))
-    assert_equal(false, organization1.shared)
-    assert_equal('Uber is a mobile app connecting passengers with drivers for hire.', organization1.note)
-
-    # case 2 - person + company
-    customer2 = User.create!(
-      firstname:     '',
-      lastname:      '',
-      email:         'me@example.com',
-      note:          '',
-      updated_by_id: 1,
-      created_by_id: 1,
-    )
-    assert(customer2)
-
-    perform_enqueued_jobs commit_transaction: true
-
-    assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer2.id))
-
-    customer2.reload
-
-    assert_equal('Martin', customer2.firstname)
-    assert_equal('Edenhofer', customer2.lastname)
-    assert_equal("Open Source professional and geek. Also known as OTRS inventor. ;)\r\nEntrepreneur and Advisor for open source people in need.", customer2.note)
-    assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2.address)
-
-    organization2 = Organization.find_by(name: 'OTRS')
-    assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization2.id))
-    assert_equal(false, organization2.shared)
-    assert_equal('OTRS is an Open Source helpdesk software and an IT Service Management software free of licence costs. Improve your Customer Service Management with OTRS.', organization2.note)
-
-    # update with own values (do not overwrite)
-    customer2.update!(
-      firstname: 'Martini',
-      note:      'changed by my self',
-    )
-
-    perform_enqueued_jobs commit_transaction: true
-
-    assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer2.id))
-
-    customer2.reload
-
-    assert_equal('Martini', customer2.firstname)
-    assert_equal('Edenhofer', customer2.lastname)
-    assert_equal('changed by my self', customer2.note)
-    assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2.address)
-
-    customer2_enrichment = Enrichment::Clearbit::User.new(customer2)
-    customer2_enrichment.synced?
-    perform_enqueued_jobs
-
-    customer2.reload
-
-    assert_equal('Martini', customer2.firstname)
-    assert_equal('Edenhofer', customer2.lastname)
-    assert_equal('changed by my self', customer2.note)
-    assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2.address)
-
-    # update with own values (do not overwrite)
-    customer2.update!(
-      firstname: '',
-      note:      'changed by my self',
-    )
-
-    customer2_enrichment = Enrichment::Clearbit::User.new(customer2)
-    customer2_enrichment.synced?
-    perform_enqueued_jobs
-
-    customer2.reload
-
-    assert_equal('Martin', customer2.firstname)
-    assert_equal('Edenhofer', customer2.lastname)
-    assert_equal('changed by my self', customer2.note)
-    assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2.address)
-
-    # update with changed values at clearbit site (do overwrite)
-    customer2.update!(
-      email: 'me2@example.com',
-    )
-
-    customer2_enrichment = Enrichment::Clearbit::User.new(customer2)
-    customer2_enrichment.synced?
-    perform_enqueued_jobs
-
-    customer2.reload
-
-    assert_equal('Martini', customer2.firstname)
-    assert_equal('Edenhofer', customer2.lastname)
-    assert_equal('changed by my self', customer2.note)
-    assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2.address)
-
-    organization2 = Organization.find_by(name: 'OTRS AG')
-    assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization2.id))
-    assert_equal(false, organization2.shared)
-    assert_equal('OTRS is an Open Source helpdesk software and an IT Service Management software free of licence costs. Improve your Customer Service Management with OTRS.', organization2.note)
-
-    # case 3 - no person
-    customer3 = User.create!(
-      firstname:     '',
-      lastname:      '',
-      email:         'testing3@znuny.com',
-      note:          '',
-      updated_by_id: 1,
-      created_by_id: 1,
-    )
-    assert(customer3)
-
-    perform_enqueued_jobs commit_transaction: true
-
-    assert_not(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer3.id))
-
-    customer3.reload
-
-    assert_equal('', customer3.firstname)
-    assert_equal('', customer3.lastname)
-    assert_equal('', customer3.note)
-    assert_equal('http://znuny.com', customer3.web)
-    assert_equal('Marienstraße 11, 10117 Berlin, Germany', customer3.address)
-
-    organization3 = Organization.find_by(name: 'Znuny / ES for OTRS')
-    assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization3.id))
-    assert_equal(false, organization3.shared)
-    assert_equal('OTRS Support, Consulting, Development, Training and Customizing - Znuny GmbH', organization3.note)
-
-    # case 4 - person with organization but organization is already assigned (own created)
-    customer4 = User.create!(
-      firstname:       '',
-      lastname:        '',
-      email:           'testing4@znuny.com',
-      note:            '',
-      organization_id: 1,
-      updated_by_id:   1,
-      created_by_id:   1,
-    )
-    assert(customer4)
-
-    perform_enqueued_jobs commit_transaction: true
-
-    assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer4.id))
-
-    customer4.reload
-
-    assert_equal('Fred', customer4.firstname)
-    assert_equal('Jupiter', customer4.lastname)
-    assert_equal('some_fred_bio', customer4.note)
-    assert_equal('http://fred.znuny.com', customer4.web)
-    assert_equal('Marienstraße 11, 10117 Berlin, Germany', customer4.address)
-
-    organization4 = Organization.find_by(name: 'ZnunyOfFred')
-    assert_not(organization4)
-
-    # case 5 - person with organization but organization is already assigned (own created)
-    customer5 = User.create!(
-      firstname:       '',
-      lastname:        '',
-      email:           'testing5@znuny.com',
-      note:            '',
-      organization_id: organization3.id,
-      updated_by_id:   1,
-      created_by_id:   1,
-    )
-    assert(customer5)
-
-    perform_enqueued_jobs commit_transaction: true
-
-    assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer5.id))
-
-    customer5.reload
-
-    assert_equal('Alex', customer5.firstname)
-    assert_equal('Dont', customer5.lastname)
-    assert_equal('some_bio_alex', customer5.note)
-    assert_equal('http://znuny.com', customer5.web)
-    assert_equal('Marienstraße 11, 10117 Berlin, Germany', customer5.address)
-
-    organization5 = Organization.find_by(name: 'Znuny GmbH')
-    assert_equal(organization3.id, organization5.id)
-    assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization5.id))
-    assert_equal(false, organization5.shared)
-    assert_equal('OTRS Support, Consulting, Development, Training and Customizing - Znuny GmbH', organization5.note)
-
-    # case 6 - no person / real api call
-    customer6 = User.create!(
-      firstname:     '',
-      lastname:      '',
-      email:         'testing6@clearbit.com',
-      note:          '',
-      updated_by_id: 1,
-      created_by_id: 1,
-    )
-    assert(customer6)
-
-    perform_enqueued_jobs commit_transaction: true
-
-    assert_not(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer6.id))
-
-    customer6.reload
-
-    assert_equal('', customer6.firstname)
-    assert_equal('', customer6.lastname)
-    assert_equal('', customer6.note)
-    assert_equal('', customer6.web)
-    # assert_equal('http://clearbit.com', customer6.web)
-    sometimes_changing_but_valid_addresses = [
-      'San Francisco, CA, USA',
-      'San Francisco, CA 94103, USA',
-      '90 Sheridan St, San Francisco, CA 94103, USA',
-      '90 Sheridan, San Francisco, CA 94103, USA',
-      '3030 16th St, San Francisco, CA 94103, USA',
-      '548 Market St, San Francisco, CA 94104, USA',
-    ]
-    assert_includes(sometimes_changing_but_valid_addresses, customer6.address)
-    organization6 = Organization.find_by('name LIKE ?', 'APIHub Inc%')
-    assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization6.id))
-    assert_equal(false, organization6.shared)
-    assert_equal('The Clearbit Data Activation Platform helps B2B teams understand customers, identify prospects, &amp; personalize interactions with real-time intelligence.', organization6.note)
-
-  end
-
-  # check
-  test 'base with invalid input' do
-    if !ENV['CLEARBIT_CI_API_KEY']
-      raise "ERROR: Need CLEARBIT_CI_API_KEY - hint CLEARBIT_CI_API_KEY='abc...'"
-    end
-
-    # set system mode to done / to activate
-    Setting.set('system_init_done', true)
-
-    Setting.set('clearbit_integration', true)
-    Setting.set('clearbit_config', {
-                  api_key:                 ENV['CLEARBIT_CI_API_KEY'],
-                  organization_autocreate: true,
-                  organization_shared:     true,
-                  user_sync:               {
-                    'person.name.givenName'  => 'user.firstname',
-                    'person.name.familyName' => 'user.lastname',
-                    'person.email'           => 'user.email',
-                    'person.bio'             => 'user.note_not_existing',
-                    'company.url'            => 'user.web',
-                    'person.site'            => 'user.web',
-                    'company.location'       => 'user.address',
-                    'person.location'        => 'user.address',
-                  },
-                  organization_sync:       {
-                    'company.legalName'   => 'organization.name',
-                    'company.name'        => 'organization.name',
-                    'company.description' => 'organization.note_not_existing',
-                  },
-                })
-
-    # case 1 - person + company (demo data set)
-    customer1 = User.create!(
-      firstname:     '',
-      lastname:      'Should be still there',
-      email:         'testing6@znuny.com',
-      note:          '',
-      updated_by_id: 1,
-      created_by_id: 1,
-    )
-    assert(customer1)
-
-    perform_enqueued_jobs commit_transaction: true
-
-    assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer1.id))
-
-    customer1.reload
-
-    assert_equal('Should', customer1.firstname)
-    assert_equal('be still there', customer1.lastname)
-    assert_equal('', customer1.note)
-    assert_equal('Marienstraße 11, 10117 Berlin, Germany', customer1.address)
-
-    organization1 = Organization.find_by(name: 'Znuny2')
-    assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization1.id))
-    assert_equal(true, organization1.shared)
-    assert_equal('', organization1.note)
-  end
-
-  class ClearbitAttributeTest < ActiveSupport::TestCase
-    include BackgroundJobsHelper
-
-    self.use_transactional_tests = false
-
-    teardown do
-      User.find_by(email: 'testing6@znuny.com').destroy
-
-      ObjectManager::Attribute.remove(
-        object: 'User',
-        name:   'attribute1',
-      )
-
-      ObjectManager::Attribute.migration_execute
-    end
-
-    test 'long value with custom attribute' do
-      if !ENV['CLEARBIT_CI_API_KEY']
-        raise "ERROR: Need CLEARBIT_CI_API_KEY - hint CLEARBIT_CI_API_KEY='abc...'"
-      end
-
-      attribute1 = ObjectManager::Attribute.add(
-        object:        'User',
-        name:          'attribute1',
-        display:       'Attribute 1',
-        data_type:     'input',
-        data_option:   {
-          maxlength: 2,
-          type:      'text',
-          null:      true,
-        },
-        active:        true,
-        screens:       {},
-        position:      20,
-        created_by_id: 1,
-        updated_by_id: 1,
-      )
-      assert(attribute1)
-
-      assert(ObjectManager::Attribute.migration_execute)
-
-      # set system mode to done / to activate
-      Setting.set('system_init_done', true)
-
-      Setting.set('clearbit_integration', true)
-      Setting.set('clearbit_config', {
-                    api_key:                 ENV['CLEARBIT_CI_API_KEY'],
-                    organization_autocreate: true,
-                    organization_shared:     true,
-                    user_sync:               {
-                      'person.name.familyName' => 'user.attribute1',
-                    },
-                    organization_sync:       {
-                      'company.legalName'   => 'organization.name',
-                      'company.name'        => 'organization.attribute1',
-                      'company.description' => 'organization.note',
-                    },
-                  })
-
-      customer1 = User.create!(
-        firstname:     '',
-        lastname:      '',
-        email:         'testing6@znuny.com',
-        note:          '',
-        updated_by_id: 1,
-        created_by_id: 1,
-      )
-      assert(customer1)
-
-      perform_enqueued_jobs commit_transaction: true
-
-      assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer1.id))
-
-      customer1.reload
-
-      assert_equal(customer1.reload.attribute1, 'Sm')
-    end
-  end
-end