Sha256: 56fa1a64c4d413d9a6d5d5cd752b96d1eb3ae2ac8ee3be0b0541ceff411b70a6

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

describe Hubspot::Event do
  let(:portal_id) { '62515' }
  let(:sent_portal_id) { portal_id }
  before { Hubspot.configure(hapikey: 'demo', portal_id: portal_id) }

  describe '.trigger' do
    let(:event_id) { '000000001625' }
    let(:email) { 'testingapis@hubspot.com' }
    let(:options) { {} }
    let(:base_url) { 'https://track.hubspot.com' }
    let(:url) { "#{base_url}/v1/event?_n=#{event_id}&_a=#{sent_portal_id}&email=#{CGI.escape email}" }

    subject { described_class.trigger(event_id, email, options) }

    before { stub_request(:get, url).to_return(status: 200, body: JSON.generate({})) }

    it('sends a request to trigger the event') { is_expected.to be true }

    context 'with headers' do
      let(:headers) { { 'User-Agent' => 'something' } }
      let(:options) { { headers: headers } }

      it('sends headers') { is_expected.to be true }
    end

    context 'when overriding portal_id' do
      let(:sent_portal_id) { '123' }
      let(:options) { { params: { _a: sent_portal_id } } }

      it('sends a request to the portal_id in the options') { is_expected.to be true }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hubspot-api-ruby-0.9.0 spec/lib/hubspot/event_spec.rb
hubspot-api-ruby-0.8.1 spec/lib/hubspot/event_spec.rb
hubspot-api-ruby-0.8.0 spec/lib/hubspot/event_spec.rb