Sha256: 566bfee01e188cb471c245ba62b3713f175356ace56a7829a2758e7752c4156e

Contents?: true

Size: 1.15 KB

Versions: 11

Compression:

Stored size: 1.15 KB

Contents

describe Hubspot::Event do
  let(:portal_id) { ENV.fetch("HUBSPOT_PORTAL_ID") }
  let(:sent_portal_id) { portal_id }

  before { Hubspot.configure(access_token: ENV.fetch("HUBSPOT_ACCESS_TOKEN"), 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

11 entries across 11 versions & 1 rubygems

Version Path
hubspot-api-ruby-0.19.0 spec/lib/hubspot/event_spec.rb
hubspot-api-ruby-0.18.0 spec/lib/hubspot/event_spec.rb
hubspot-api-ruby-0.17.1 spec/lib/hubspot/event_spec.rb
hubspot-api-ruby-0.17.0 spec/lib/hubspot/event_spec.rb
hubspot-api-ruby-0.16.0 spec/lib/hubspot/event_spec.rb
hubspot-api-ruby-0.15.0 spec/lib/hubspot/event_spec.rb
hubspot-api-ruby-0.14.0 spec/lib/hubspot/event_spec.rb
hubspot-api-ruby-0.13.0 spec/lib/hubspot/event_spec.rb
hubspot-api-ruby-0.12.0 spec/lib/hubspot/event_spec.rb
hubspot-api-ruby-0.11.0 spec/lib/hubspot/event_spec.rb
hubspot-api-ruby-0.10.0 spec/lib/hubspot/event_spec.rb