netsuite 0.8.2 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.ruby-version +1 -1
  4. data/Gemfile +7 -2
  5. data/README.md +107 -32
  6. data/circle.yml +33 -13
  7. data/lib/netsuite.rb +36 -19
  8. data/lib/netsuite/actions/login.rb +20 -1
  9. data/lib/netsuite/actions/search.rb +1 -6
  10. data/lib/netsuite/actions/update.rb +6 -2
  11. data/lib/netsuite/actions/update_list.rb +109 -0
  12. data/lib/netsuite/actions/upsert.rb +2 -0
  13. data/lib/netsuite/configuration.rb +21 -4
  14. data/lib/netsuite/errors.rb +1 -0
  15. data/lib/netsuite/records/assembly_build.rb +4 -1
  16. data/lib/netsuite/records/assembly_item.rb +1 -0
  17. data/lib/netsuite/records/assembly_unbuild.rb +3 -0
  18. data/lib/netsuite/records/bin_number.rb +18 -0
  19. data/lib/netsuite/records/bin_number_list.rb +1 -20
  20. data/lib/netsuite/records/bin_transfer.rb +38 -0
  21. data/lib/netsuite/records/bin_transfer_inventory.rb +20 -0
  22. data/lib/netsuite/records/bin_transfer_inventory_list.rb +10 -0
  23. data/lib/netsuite/records/cash_refund_item.rb +1 -1
  24. data/lib/netsuite/records/classification.rb +5 -2
  25. data/lib/netsuite/records/custom_field_list.rb +10 -2
  26. data/lib/netsuite/records/custom_record.rb +3 -3
  27. data/lib/netsuite/records/custom_record_ref.rb +1 -0
  28. data/lib/netsuite/records/customer.rb +5 -4
  29. data/lib/netsuite/records/customer_credit_cards.rb +36 -0
  30. data/lib/netsuite/records/customer_credit_cards_list.rb +10 -0
  31. data/lib/netsuite/records/customer_deposit.rb +5 -2
  32. data/lib/netsuite/records/customer_payment.rb +1 -0
  33. data/lib/netsuite/records/customer_sales_team.rb +24 -0
  34. data/lib/netsuite/records/customer_sales_team_list.rb +9 -0
  35. data/lib/netsuite/records/customer_status.rb +29 -0
  36. data/lib/netsuite/records/customer_subscription.rb +18 -0
  37. data/lib/netsuite/records/customer_subscriptions_list.rb +10 -0
  38. data/lib/netsuite/records/employee.rb +1 -1
  39. data/lib/netsuite/records/entity_custom_field.rb +53 -0
  40. data/lib/netsuite/records/estimate.rb +42 -0
  41. data/lib/netsuite/records/estimate_item.rb +40 -0
  42. data/lib/netsuite/records/estimate_item_list.rb +11 -0
  43. data/lib/netsuite/records/inbound_shipment.rb +33 -0
  44. data/lib/netsuite/records/inbound_shipment_item.rb +39 -0
  45. data/lib/netsuite/records/inbound_shipment_item_list.rb +11 -0
  46. data/lib/netsuite/records/inter_company_journal_entry.rb +48 -0
  47. data/lib/netsuite/records/inter_company_journal_entry_line.rb +28 -0
  48. data/lib/netsuite/records/inter_company_journal_entry_line_list.rb +14 -0
  49. data/lib/netsuite/records/inventory_item.rb +1 -1
  50. data/lib/netsuite/records/invoice.rb +1 -1
  51. data/lib/netsuite/records/item_fulfillment.rb +1 -1
  52. data/lib/netsuite/records/lot_numbered_inventory_item.rb +116 -0
  53. data/lib/netsuite/records/matrix_option_list.rb +12 -4
  54. data/lib/netsuite/records/message.rb +30 -0
  55. data/lib/netsuite/records/non_inventory_resale_item.rb +3 -2
  56. data/lib/netsuite/records/non_inventory_sale_item.rb +1 -1
  57. data/lib/netsuite/records/other_charge_sale_item.rb +2 -2
  58. data/lib/netsuite/records/partner.rb +1 -1
  59. data/lib/netsuite/records/price.rb +17 -0
  60. data/lib/netsuite/records/price_level.rb +26 -0
  61. data/lib/netsuite/records/price_list.rb +9 -0
  62. data/lib/netsuite/records/pricing.rb +20 -0
  63. data/lib/netsuite/records/pricing_matrix.rb +2 -2
  64. data/lib/netsuite/records/promotions.rb +26 -0
  65. data/lib/netsuite/records/promotions_list.rb +9 -0
  66. data/lib/netsuite/records/return_authorization_item.rb +1 -1
  67. data/lib/netsuite/records/sales_order.rb +1 -0
  68. data/lib/netsuite/records/sales_order_item.rb +12 -5
  69. data/lib/netsuite/records/sales_role.rb +26 -0
  70. data/lib/netsuite/records/sales_tax_item.rb +3 -1
  71. data/lib/netsuite/records/serialized_assembly_item.rb +239 -0
  72. data/lib/netsuite/records/service_resale_item.rb +1 -1
  73. data/lib/netsuite/records/service_sale_item.rb +1 -1
  74. data/lib/netsuite/records/support_case.rb +1 -1
  75. data/lib/netsuite/records/support_case_type.rb +26 -0
  76. data/lib/netsuite/records/tax_group.rb +2 -2
  77. data/lib/netsuite/records/transaction_body_custom_field.rb +61 -0
  78. data/lib/netsuite/records/transaction_column_custom_field.rb +59 -0
  79. data/lib/netsuite/records/vendor_credit.rb +2 -0
  80. data/lib/netsuite/records/work_order.rb +8 -0
  81. data/lib/netsuite/support/actions.rb +2 -0
  82. data/lib/netsuite/support/country.rb +27 -15
  83. data/lib/netsuite/support/search_result.rb +20 -5
  84. data/lib/netsuite/utilities.rb +83 -21
  85. data/lib/netsuite/version.rb +1 -1
  86. data/netsuite.gemspec +4 -3
  87. data/spec/netsuite/actions/login_spec.rb +23 -0
  88. data/spec/netsuite/actions/update_list_spec.rb +107 -0
  89. data/spec/netsuite/actions/update_spec.rb +42 -0
  90. data/spec/netsuite/configuration_spec.rb +79 -6
  91. data/spec/netsuite/records/address_spec.rb +10 -0
  92. data/spec/netsuite/records/basic_record_spec.rb +11 -1
  93. data/spec/netsuite/records/bin_number_spec.rb +23 -0
  94. data/spec/netsuite/records/classification_spec.rb +10 -1
  95. data/spec/netsuite/records/custom_field_list_spec.rb +39 -4
  96. data/spec/netsuite/records/custom_record_spec.rb +1 -1
  97. data/spec/netsuite/records/customer_credit_cards_list_spec.rb +23 -0
  98. data/spec/netsuite/records/customer_sales_team_list_spec.rb +41 -0
  99. data/spec/netsuite/records/customer_spec.rb +44 -2
  100. data/spec/netsuite/records/customer_subscription_spec.rb +41 -0
  101. data/spec/netsuite/records/customer_subscriptions_list_spec.rb +19 -0
  102. data/spec/netsuite/records/employee_spec.rb +2 -2
  103. data/spec/netsuite/records/entity_custom_field_spec.rb +34 -0
  104. data/spec/netsuite/records/estimate_item_list_spec.rb +26 -0
  105. data/spec/netsuite/records/estimate_item_spec.rb +40 -0
  106. data/spec/netsuite/records/estimate_spec.rb +216 -0
  107. data/spec/netsuite/records/inter_company_journal_entry_line_list_spec.rb +26 -0
  108. data/spec/netsuite/records/inter_company_journal_entry_line_spec.rb +60 -0
  109. data/spec/netsuite/records/inter_company_journal_entry_spec.rb +156 -0
  110. data/spec/netsuite/records/inventory_item_spec.rb +57 -0
  111. data/spec/netsuite/records/matrix_option_list_spec.rb +15 -5
  112. data/spec/netsuite/records/message_spec.rb +49 -0
  113. data/spec/netsuite/records/non_inventory_resale_item_spec.rb +165 -0
  114. data/spec/netsuite/records/non_inventory_sale_item_spec.rb +1 -1
  115. data/spec/netsuite/records/partner_spec.rb +141 -0
  116. data/spec/netsuite/records/price_level_spec.rb +16 -0
  117. data/spec/netsuite/records/pricing_matrix_spec.rb +15 -13
  118. data/spec/netsuite/records/return_authorization_item_spec.rb +1 -1
  119. data/spec/netsuite/records/sales_order_item_spec.rb +11 -5
  120. data/spec/netsuite/records/service_resale_item_spec.rb +134 -0
  121. data/spec/netsuite/records/support_case_type_spec.rb +22 -0
  122. data/spec/netsuite/records/transaction_body_custom_field_spec.rb +32 -0
  123. data/spec/netsuite/records/transaction_column_custom_field_spec.rb +32 -0
  124. data/spec/netsuite/records/vendor_credit_spec.rb +29 -0
  125. data/spec/netsuite/support/search_result_spec.rb +24 -0
  126. data/spec/netsuite/utilities_spec.rb +44 -6
  127. data/spec/spec_helper.rb +5 -4
  128. data/spec/support/fixtures/update_list/update_list_items.xml +22 -0
  129. data/spec/support/fixtures/update_list/update_list_one_item.xml +18 -0
  130. data/spec/support/fixtures/update_list/update_list_with_errors.xml +32 -0
  131. metadata +101 -8
@@ -1,3 +1,3 @@
1
1
  module NetSuite
2
- VERSION = '0.8.2'
2
+ VERSION = '0.8.6'
3
3
  end
@@ -2,8 +2,9 @@
2
2
  require File.expand_path('../lib/netsuite/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
+ gem.licenses = ['MIT']
5
6
  gem.authors = ['Ryan Moran', 'Michael Bianco']
6
- gem.email = ['ryan.moran@gmail.com', 'mike@cliffsidemedia.com']
7
+ gem.email = ['ryan.moran@gmail.com', 'mike@mikebian.co']
7
8
  gem.description = %q{NetSuite SuiteTalk API Wrapper}
8
9
  gem.summary = %q{NetSuite SuiteTalk API (SOAP) Wrapper}
9
10
  gem.homepage = 'https://github.com/NetSweet/netsuite'
@@ -15,7 +16,7 @@ Gem::Specification.new do |gem|
15
16
  gem.require_paths = ['lib']
16
17
  gem.version = NetSuite::VERSION
17
18
 
18
- gem.add_dependency 'savon', '>= 2.3.0'
19
+ gem.add_dependency 'savon', '>= 2.3.0', '<= 2.11.1'
19
20
 
20
- gem.add_development_dependency 'rspec', '~> 3.1.0'
21
+ gem.add_development_dependency 'rspec', '~> 3.8.0'
21
22
  end
@@ -41,4 +41,27 @@ describe NetSuite::Actions::Login do
41
41
  role: 234
42
42
  }) }.to raise_error(Savon::SOAPFault)
43
43
  end
44
+
45
+ it 'handles a login call when token based auth is in place' do
46
+ NetSuite.configure do
47
+ consumer_key '123'
48
+ consumer_secret '123'
49
+ token_id '123'
50
+ token_secret '123'
51
+
52
+ api_version '2017_2'
53
+ end
54
+
55
+ message = {"platformMsgs:passport"=>{"platformCore:email"=>"email", "platformCore:password"=>"password", "platformCore:account"=>"1234", "platformCore:role"=>234}}
56
+ savon.expects(:login).with(:message => message).returns(File.read('spec/support/fixtures/login/success.xml'))
57
+
58
+ result = NetSuite::Actions::Login.call({
59
+ email: 'email',
60
+ password: 'password',
61
+ role: 234
62
+ })
63
+
64
+ expect(result.success?).to eq(true)
65
+ expect(result.body[:user_id]).to_not be_nil
66
+ end
44
67
  end
@@ -0,0 +1,107 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Actions::UpdateList do
4
+ before { savon.mock! }
5
+ after { savon.unmock! }
6
+
7
+ context 'Items' do
8
+ context 'one item' do
9
+ let(:item) do
10
+ [
11
+ NetSuite::Records::InventoryItem.new(internal_id: '624113', item_id: 'Target', upccode: 'Target')
12
+ ]
13
+ end
14
+
15
+ before do
16
+ savon.expects(:update_list).with(:message =>
17
+ {
18
+ 'record' => [{
19
+ 'listAcct:itemId' => 'Target',
20
+ '@xsi:type' => 'listAcct:InventoryItem',
21
+ '@internalId' => '624113'
22
+ }]
23
+ }).returns(File.read('spec/support/fixtures/update_list/update_list_one_item.xml'))
24
+ end
25
+
26
+ it 'makes a valid request to the NetSuite API' do
27
+ NetSuite::Actions::UpdateList.call(item)
28
+ end
29
+
30
+ it 'returns a valid Response object' do
31
+ response = NetSuite::Actions::UpdateList.call(item)
32
+ expect(response).to be_kind_of(NetSuite::Response)
33
+ expect(response).to be_success
34
+ end
35
+ end
36
+
37
+ context 'two items' do
38
+ let(:items) do
39
+ [
40
+ NetSuite::Records::InventoryItem.new(internal_id: '624172', item_id: 'Shutter Fly', upccode: 'Shutter Fly, Inc.'),
41
+ NetSuite::Records::InventoryItem.new(internal_id: '624113', item_id: 'Target', upccode: 'Target')
42
+ ]
43
+ end
44
+
45
+ before do
46
+ savon.expects(:update_list).with(:message =>
47
+ {
48
+ 'record' => [{
49
+ 'listAcct:itemId' => 'Shutter Fly',
50
+ '@xsi:type' => 'listAcct:InventoryItem',
51
+ '@internalId' => '624172'
52
+ },
53
+ {
54
+ 'listAcct:itemId' => 'Target',
55
+ '@xsi:type' => 'listAcct:InventoryItem',
56
+ '@internalId' => '624113'
57
+ }
58
+ ]
59
+ }).returns(File.read('spec/support/fixtures/update_list/update_list_items.xml'))
60
+ end
61
+
62
+ it 'makes a valid request to the NetSuite API' do
63
+ NetSuite::Actions::UpdateList.call(items)
64
+ end
65
+
66
+ it 'returns a valid Response object' do
67
+ response = NetSuite::Actions::UpdateList.call(items)
68
+ expect(response).to be_kind_of(NetSuite::Response)
69
+ expect(response).to be_success
70
+ end
71
+ end
72
+ end
73
+
74
+ context 'with errors' do
75
+ let(:items) do
76
+ [
77
+ NetSuite::Records::InventoryItem.new(internal_id: '624172-bad', item_id: 'Shutter Fly', upccode: 'Shutter Fly, Inc.'),
78
+ NetSuite::Records::InventoryItem.new(internal_id: '624113-bad', item_id: 'Target', upccode: 'Target')
79
+ ]
80
+ end
81
+
82
+ before do
83
+ savon.expects(:update_list).with(:message =>
84
+ {
85
+ 'record' => [{
86
+ 'listAcct:itemId' => 'Shutter Fly',
87
+ '@xsi:type' => 'listAcct:InventoryItem',
88
+ '@internalId' => '624172-bad'
89
+ },
90
+ {
91
+ 'listAcct:itemId' => 'Target',
92
+ '@xsi:type' => 'listAcct:InventoryItem',
93
+ '@internalId' => '624113-bad'
94
+ }
95
+ ]
96
+ }).returns(File.read('spec/support/fixtures/update_list/update_list_with_errors.xml'))
97
+ end
98
+
99
+ it 'constructs error objects' do
100
+ response = NetSuite::Actions::UpdateList.call(items)
101
+ expect(response.errors.keys).to match_array(['624172', '624113'])
102
+ expect(response.errors['624172'].first.code).to eq('USER_ERROR')
103
+ expect(response.errors['624172'].first.message).to eq('Please enter value(s) for: ItemId')
104
+ expect(response.errors['624172'].first.type).to eq('ERROR')
105
+ end
106
+ end
107
+ end
@@ -19,6 +19,48 @@ describe NetSuite::Actions::Update do
19
19
  }
20
20
  end
21
21
 
22
+ describe 'updating the external ID' do
23
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
24
+
25
+ # https://github.com/NetSweet/netsuite/pull/416
26
+ # if the external ID is set, and the external ID field is ommitted on an update, the external ID field does not change
27
+ # if the external_id field is set to nil, it should not be passed to netsuite
28
+ # passing an empty string to the external ID field does not remove it
29
+
30
+ it 'does not pass the external ID to an update call if not modified or included in update options' do
31
+ expect(NetSuite::Actions::Update).to receive(:call).
32
+ with([customer.class, {}], {}).
33
+ and_return(response)
34
+
35
+ expect(customer.update).to be_truthy
36
+ end
37
+
38
+ it 'should update the external ID when the attribute on the record is set' do
39
+ expect(NetSuite::Actions::Update).to receive(:call).
40
+ with([customer.class, {external_id: 'foo'}], {}).
41
+ and_return(response)
42
+
43
+ customer.external_id = 'foo'
44
+ expect(customer.update).to be_truthy
45
+ end
46
+
47
+ it 'should update the external ID to nil when the attribute on the record is set' do
48
+ expect(NetSuite::Actions::Update).to receive(:call).
49
+ with([customer.class, {external_id: nil}], {}).
50
+ and_return(response)
51
+
52
+ expect(customer.update(external_id: nil)).to be_truthy
53
+ end
54
+
55
+ it 'should update the external ID to the options value not the attribute value' do
56
+ expect(NetSuite::Actions::Update).to receive(:call).
57
+ with([customer.class, {external_id: 'bar'}], {}).
58
+ and_return(response)
59
+
60
+ customer.external_id = 'foo'
61
+ expect(customer.update(external_id: 'bar')).to be_truthy
62
+ end
63
+ end
22
64
 
23
65
  context 'when successful' do
24
66
 
@@ -326,15 +326,11 @@ describe NetSuite::Configuration do
326
326
 
327
327
  describe "#credentials" do
328
328
  context "when none are defined" do
329
- skip "should properly create the auth credentials" do
330
-
331
- end
329
+ skip "should properly create the auth credentials"
332
330
  end
333
331
 
334
332
  context "when they are defined" do
335
- it "should properly replace the default auth credentials" do
336
-
337
- end
333
+ skip "should properly replace the default auth credentials"
338
334
  end
339
335
  end
340
336
 
@@ -371,4 +367,81 @@ describe NetSuite::Configuration do
371
367
  end
372
368
  end
373
369
 
370
+ describe "#log" do
371
+ it 'allows a file path to be set as the log destination' do
372
+ file_path = Tempfile.new.path
373
+ config.log = file_path
374
+ config.logger.info "foo"
375
+
376
+ log_contents = open(file_path).read
377
+ expect(log_contents).to include("foo")
378
+ end
379
+
380
+ it 'allows an IO device to bet set as the log destination' do
381
+ stream = StringIO.new
382
+ config.log = stream
383
+ config.logger.info "foo"
384
+
385
+ expect(stream.string).to include("foo")
386
+ end
387
+ end
388
+
389
+ describe '#log_level' do
390
+ it 'defaults to :debug' do
391
+ expect(config.log_level).to eq(:debug)
392
+ end
393
+
394
+ it 'can be initially set to any log level' do
395
+ config.log_level(:info)
396
+
397
+ expect(config.log_level).to eq(:info)
398
+ end
399
+
400
+ it 'can override itself' do
401
+ config.log_level = :info
402
+
403
+ expect(config.log_level).to eq(:info)
404
+
405
+ config.log_level(:debug)
406
+
407
+ expect(config.log_level).to eq(:debug)
408
+ end
409
+ end
410
+
411
+ describe '#log_level=' do
412
+ it 'can set the initial log_level' do
413
+ config.log_level = :info
414
+
415
+ expect(config.log_level).to eq(:info)
416
+ end
417
+
418
+ it 'can override a previously set log level' do
419
+ config.log_level = :info
420
+
421
+ expect(config.log_level).to eq(:info)
422
+
423
+ config.log_level = :debug
424
+
425
+ expect(config.log_level).to eq(:debug)
426
+ end
427
+ end
428
+
429
+ describe 'timeouts' do
430
+ it 'has defaults' do
431
+ expect(config.read_timeout).to eql(60)
432
+ expect(config.open_timeout).to be_nil
433
+ end
434
+
435
+ it 'sets timeouts' do
436
+ config.read_timeout = 100
437
+ config.open_timeout = 60
438
+
439
+ expect(config.read_timeout).to eql(100)
440
+ expect(config.open_timeout).to eql(60)
441
+
442
+ # ensure no exception is raised
443
+ config.connection
444
+ end
445
+ end
446
+
374
447
  end
@@ -134,6 +134,16 @@ describe NetSuite::Records::Address do
134
134
  expect(addressbook.country.to_record).to eql ""
135
135
  expect(addressbook.to_record["platformCommon:country"]).to eql ""
136
136
  end
137
+
138
+ it 'changes the netsuite identifier based on the current API version' do
139
+ NetSuite::Configuration.api_version = '2015_1'
140
+ addressbook = NetSuite::Records::Address.new country: "GB"
141
+ expect(addressbook.to_record["platformCommon:country"]).to eql "_unitedKingdomGB"
142
+ NetSuite::Configuration.api_version = '2018_1'
143
+
144
+ addressbook = NetSuite::Records::Address.new country: "GB"
145
+ expect(addressbook.to_record["platformCommon:country"]).to eql "_unitedKingdom"
146
+ end
137
147
  end
138
148
 
139
149
  end
@@ -25,6 +25,7 @@ describe 'basic records' do
25
25
  NetSuite::Records::CustomerDeposit,
26
26
  NetSuite::Records::NonInventoryPurchaseItem,
27
27
  NetSuite::Records::NonInventoryResaleItem,
28
+ NetSuite::Records::LotNumberedInventoryItem,
28
29
  NetSuite::Records::TaxGroup,
29
30
  NetSuite::Records::Folder,
30
31
  NetSuite::Records::CustomerCategory,
@@ -53,7 +54,16 @@ describe 'basic records' do
53
54
  NetSuite::Records::AssemblyUnbuild,
54
55
  NetSuite::Records::AssemblyComponent,
55
56
  NetSuite::Records::InventoryNumber,
56
- NetSuite::Records::LotNumberedAssemblyItem
57
+ NetSuite::Records::PriceLevel,
58
+ NetSuite::Records::LotNumberedAssemblyItem,
59
+ NetSuite::Records::InboundShipment,
60
+ NetSuite::Records::InterCompanyJournalEntry,
61
+ NetSuite::Records::BinTransfer,
62
+ NetSuite::Records::SerializedAssemblyItem,
63
+ NetSuite::Records::CustomerStatus,
64
+ NetSuite::Records::TransactionBodyCustomField,
65
+ NetSuite::Records::TransactionColumnCustomField,
66
+ NetSuite::Records::EntityCustomField
57
67
  ]
58
68
  }
59
69
 
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::BinNumber do
4
+ it "has all the right fields" do
5
+ bin_number = described_class.new
6
+
7
+ [:preferred_bin, :location].each do |field|
8
+ expect(bin_number).to have_field(field)
9
+ end
10
+ end
11
+
12
+ it "has all the right record refs" do
13
+ bin_number = described_class.new
14
+
15
+ expect(bin_number).to have_record_ref(:bin_number)
16
+ end
17
+
18
+ it "has the right namespace" do
19
+ bin_number = described_class.new
20
+
21
+ expect(bin_number.record_namespace).to eq('listAcct')
22
+ end
23
+ end
@@ -5,12 +5,21 @@ describe NetSuite::Records::Classification do
5
5
 
6
6
  it 'has all the right fields' do
7
7
  [
8
- :name, :include_children, :is_inactive, :class_translation_list, :custom_field_list
8
+ :name, :include_children, :is_inactive, :class_translation_list
9
9
  ].each do |field|
10
10
  expect(classification).to have_field(field)
11
11
  end
12
12
 
13
13
  expect(classification.subsidiary_list.class).to eq(NetSuite::Records::RecordRefList)
14
+ expect(classification.custom_field_list.class).to eq(NetSuite::Records::CustomFieldList)
15
+ end
16
+
17
+ it 'has all the right record refs' do
18
+ [
19
+ :parent
20
+ ].each do |record_ref|
21
+ expect(classification).to have_record_ref(record_ref)
22
+ end
14
23
  end
15
24
 
16
25
  describe '.get' do
@@ -37,9 +37,11 @@ describe NetSuite::Records::CustomFieldList do
37
37
  context 'writing convience methods' do
38
38
  it "should create a custom field entry when none exists" do
39
39
  list.custrecord_somefield = 'a value'
40
- list.custom_fields.size.should == 1
41
- list.custom_fields.first.value.should == 'a value'
42
- list.custom_fields.first.type.should == 'platformCore:StringCustomFieldRef'
40
+ custom_fields = list.custom_fields
41
+
42
+ expect(custom_fields.size).to eq(1)
43
+ expect(custom_fields.first.value).to eq('a value')
44
+ expect(custom_fields.first.type).to eq('platformCore:StringCustomFieldRef')
43
45
  end
44
46
 
45
47
  # https://github.com/NetSweet/netsuite/issues/325
@@ -116,7 +118,7 @@ describe NetSuite::Records::CustomFieldList do
116
118
  end
117
119
 
118
120
  it "should raise an error if custom field entry does not exist" do
119
- expect{ list.nonexisting_custom_field }.to raise_error
121
+ expect{ list.nonexisting_custom_field }.to raise_error(NoMethodError)
120
122
  end
121
123
  end
122
124
  end
@@ -180,6 +182,20 @@ describe NetSuite::Records::CustomFieldList do
180
182
  script_id: "custbody_salesclassification",
181
183
  type: "platformCore:StringCustomFieldRef",
182
184
  value: "foobar"
185
+ },
186
+ {
187
+ script_id: 'custbody_multipleselectfield',
188
+ type: "platformCore:MultiSelectCustomFieldRef",
189
+ value: [
190
+ {
191
+ internal_id: 405,
192
+ type_id: 157
193
+ },
194
+ {
195
+ internal_id: 419,
196
+ type_id: 157
197
+ }
198
+ ]
183
199
  }
184
200
  ]
185
201
  }
@@ -200,9 +216,28 @@ describe NetSuite::Records::CustomFieldList do
200
216
  "@xsi:type" => "platformCore:StringCustomFieldRef",
201
217
  "platformCore:value" => "foobar",
202
218
  },
219
+ {
220
+ '@scriptId' => 'custbody_multipleselectfield',
221
+ '@xsi:type' => 'platformCore:MultiSelectCustomFieldRef',
222
+ 'platformCore:value' => [
223
+ {
224
+ :@internalId => 405,
225
+ :@typeId => "157"
226
+ },
227
+ {
228
+ :@internalId => 419,
229
+ :@typeId => "157"
230
+ }
231
+ ]
232
+ }
203
233
  ]
204
234
  }
205
235
 
236
+ # field accessors are tested elsewhere, but let's run tests here to check various field types
237
+ expect(list).to respond_to(:custbody_multipleselectfield)
238
+ expect(list).to respond_to(:custbody_salesclassification)
239
+ expect(list).to respond_to(:custentity_registeredonline)
240
+
206
241
  expect(list.to_record).to eql(record)
207
242
  expect(list.to_record.length).to eq(1)
208
243
  end