Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hubspot): create hubspot company with domain #3844

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/integrations/lead_tracking/hubspot/lead_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def update_company_active_subscription(
def _get_or_create_company_by_domain(self, domain: str) -> dict:
company = self.client.get_company_by_domain(domain)
if not company:
company = self.client.create_company(name=domain)
company = self.client.create_company(name=domain, domain=domain)

return company

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ def test_track_hubspot_lead_without_organisation(
# Given
hubspot_company_id = "company-id"
hubspot_contact_id = "contact-id"
domain = "example.com"
email = f"test@{domain}"

settings.ENABLE_HUBSPOT_LEAD_TRACKING = True

user = FFAdminUser.objects.create(email="[email protected]")
user = FFAdminUser.objects.create(email=email)

mock_hubspot_client = mocker.MagicMock(spec=HubspotClient)
mocker.patch(
Expand All @@ -56,5 +58,8 @@ def test_track_hubspot_lead_without_organisation(
track_hubspot_lead_without_organisation(user_id=user.id)

# Then
mock_hubspot_client.create_company.assert_called_once_with(
name=domain, domain=domain
)
mock_hubspot_client.create_contact.assert_called_once_with(user, hubspot_company_id)
assert HubspotLead.objects.filter(user=user).exists()