Sha256: 65ecacc29eea6b1969879e95e9c26c4a6081586e683e90d686b8f92b45d0467d

Contents?: true

Size: 2 KB

Versions: 18

Compression:

Stored size: 2 KB

Contents

require 'spec_helper'

describe NetSuite::Records::Location do
  let(:location) { NetSuite::Records::Location.new }

  # <element name="classTranslationList" type="listAcct:ClassTranslationList" minOccurs="0"/>
  # <element name="subsidiaryList" type="platformCore:RecordRefList" minOccurs="0"/>
  # <element name="customFieldList" type="platformCore:CustomFieldList" minOccurs="0"/>
  it 'has all the right attributes' do
    [
      :addr1, :addr2, :addr3, :addr_phone, :addr_text, :addressee, :attention, :city, :country, :include_children, :is_inactive,
      :make_inventory_available, :make_inventory_available_store, :name, :override, :state, :tran_prefix, :zip
    ].each do |field|
      location.should have_field(field)
    end
  end

  it 'has all the right record refs' do
    [
      :logo, :parent
    ].each do |record_ref|
      location.should have_record_ref(record_ref)
    end
  end

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

      it 'returns a Location instance populated with the data from the response object' do
        NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::Location, :external_id => 1).and_return(response)
        location = NetSuite::Records::Location.get(:external_id => 1)
        location.should be_kind_of(NetSuite::Records::Location)
        location.city.should eql('Los Angeles')
      end
    end

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

      it 'raises a RecordNotFound exception' do
        NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::Location, :external_id => 1).and_return(response)
        lambda {
          NetSuite::Records::Location.get(:external_id => 1)
        }.should raise_error(NetSuite::RecordNotFound,
          /NetSuite::Records::Location with OPTIONS=(.*) could not be found/)
      end
    end
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
netsuite-0.0.39 spec/netsuite/records/location_spec.rb
netsuite-0.0.38 spec/netsuite/records/location_spec.rb
netsuite-0.0.37 spec/netsuite/records/location_spec.rb
netsuite-0.0.36 spec/netsuite/records/location_spec.rb
netsuite-0.0.35 spec/netsuite/records/location_spec.rb
netsuite-0.0.34 spec/netsuite/records/location_spec.rb
netsuite-0.0.33 spec/netsuite/records/location_spec.rb
netsuite-0.0.32 spec/netsuite/records/location_spec.rb
netsuite-0.0.31 spec/netsuite/records/location_spec.rb
netsuite-0.0.30 spec/netsuite/records/location_spec.rb
netsuite-0.0.29 spec/netsuite/records/location_spec.rb
netsuite-0.0.28 spec/netsuite/records/location_spec.rb
netsuite-0.0.27 spec/netsuite/records/location_spec.rb
netsuite-0.0.26 spec/netsuite/records/location_spec.rb
netsuite-0.0.25 spec/netsuite/records/location_spec.rb
netsuite-0.0.23 spec/netsuite/records/location_spec.rb
netsuite-0.0.22 spec/netsuite/records/location_spec.rb
netsuite-0.0.21 spec/netsuite/records/location_spec.rb