Sha256: 6e24a74bb1efd98176d7821968563d8f659312746396e3e2b1157412496e8a6f

Contents?: true

Size: 1.84 KB

Versions: 60

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'

describe NetSuite::Records::Campaign do
  let(:campaign) { NetSuite::Records::Campaign.new }

  it 'has all the right fields' do
    [ :audience, :base_cost, :campaign_direct_mail_list, :campaign_email_list,
      :campaign_event_list, :campaign_id, :category, :conv_cost_per_customer, :conversions,
      :cost, :cost_per_customer, :end_date, :event_response_list, :expected_revenue,
      :family, :is_inactive, :item_list, :keyword, :leads_generated, :message,
      :offer, :owner, :profit, :promotion_code, :roi, :search_engine, :start_date, :title,
      :total_revenue, :unique_visitors, :url, :vertical
    ].each do |field|
      expect(campaign).to have_field(field)
    end
  end

  describe '.get' do
    context 'when the response is successful' do
      let(:response) { NetSuite::Response.new(:success => true, :body => { :message => 'Message 1' }) }

      it 'returns a Campaign instance populated with the data from the response object' do
        expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::Campaign, {:external_id => 1}], {}).and_return(response)
        campaign = NetSuite::Records::Campaign.get(:external_id => 1)
        expect(campaign).to be_kind_of(NetSuite::Records::Campaign)
        expect(campaign.message).to eql('Message 1')
      end
    end

    context 'when the response is unsuccessful' do
      let(:response) { NetSuite::Response.new(:success => false, :body => {}) }

      it 'raises a RecordNotFound exception' do
        expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::Campaign, {:external_id => 1}], {}).and_return(response)
        expect {
          NetSuite::Records::Campaign.get(:external_id => 1)
        }.to raise_error(NetSuite::RecordNotFound,
          /NetSuite::Records::Campaign with OPTIONS=(.*) could not be found/)
      end
    end
  end

end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
netsuite-0.5.6 spec/netsuite/records/campaign_spec.rb
netsuite-0.5.5 spec/netsuite/records/campaign_spec.rb
netsuite-0.5.4 spec/netsuite/records/campaign_spec.rb
netsuite-0.5.3 spec/netsuite/records/campaign_spec.rb
netsuite-0.5.2 spec/netsuite/records/campaign_spec.rb
netsuite-0.5.1 spec/netsuite/records/campaign_spec.rb
netsuite-0.5.0 spec/netsuite/records/campaign_spec.rb
netsuite-0.4.9 spec/netsuite/records/campaign_spec.rb
netsuite-0.4.8 spec/netsuite/records/campaign_spec.rb
netsuite-0.4.7 spec/netsuite/records/campaign_spec.rb
netsuite-0.4.6 spec/netsuite/records/campaign_spec.rb
netsuite-0.4.5 spec/netsuite/records/campaign_spec.rb
netsuite-0.4.4 spec/netsuite/records/campaign_spec.rb
netsuite-0.4.3 spec/netsuite/records/campaign_spec.rb
netsuite-0.4.2 spec/netsuite/records/campaign_spec.rb
netsuite-0.4.1 spec/netsuite/records/campaign_spec.rb
netsuite-0.4.0 spec/netsuite/records/campaign_spec.rb
netsuite-0.3.3 spec/netsuite/records/campaign_spec.rb
netsuite-0.3.2 spec/netsuite/records/campaign_spec.rb
netsuite-0.3.1 spec/netsuite/records/campaign_spec.rb