spec/netsuite/actions/search_spec.rb in netsuite-0.9.2 vs spec/netsuite/actions/search_spec.rb in netsuite-0.9.3
- old
+ new
@@ -3,26 +3,33 @@
describe NetSuite::Actions::Search do
before(:all) { savon.mock! }
after(:all) { savon.unmock! }
it "handles custom auth credentials" do
- allow(NetSuite::Configuration).to receive(:connection).and_return(double().as_null_object)
-
credentials = {
email: 'fake@domain.com',
password: 'fake'
}
- NetSuite::Records::Customer.search({}, credentials)
- expect(NetSuite::Configuration).to have_received(:connection).with({:soap_header=>{
+ connection = NetSuite::Configuration.connection({}, credentials)
+
+ soap_header = {
"platformMsgs:passport"=>{
"platformCore:email"=>"fake@domain.com",
"platformCore:password"=>"fake",
"platformCore:account"=>"1234",
"platformCore:role"=>{:@internalId=>"3"}
- }, "platformMsgs:SearchPreferences"=>{}}}, credentials
- )
+ }
+ }
+
+ expect(connection.instance_variable_get('@globals')[:soap_header]).to eq soap_header
+
+ allow(NetSuite::Configuration).to receive(:connection).and_return(double().as_null_object)
+
+ NetSuite::Records::Customer.search({}, credentials)
+
+ expect(NetSuite::Configuration).to have_received(:connection).with({}, credentials, { "platformMsgs:SearchPreferences"=>{} })
end
context "search class name" do
it "infers class name if class doesn't specify search class" do
instance = described_class.new NetSuite::Records::Customer
@@ -190,33 +197,9 @@
search = NetSuite::Records::InventoryItem.search(saved: 42)
expect(search.results.first.location_quantity_available).to eq('3307.0')
expect(search.results.first.location_re_order_point).to eq('2565.0')
expect(search.results.first.location_quantity_on_order).to eq('40000.0')
- end
-
- it "should handle an ID search with basic non-field result columns" do
- response = File.read('spec/support/fixtures/search/saved_search_item_2.xml')
- savon.expects(:search)
- .with(message: {
- "searchRecord"=>{
- "@xsi:type" =>"listAcct:ItemSearchAdvanced",
- "@savedSearchId" =>42,
- :content! =>{"listAcct:criteria"=>{}},
- }
- }).returns(response)
-
- search = NetSuite::Records::InventoryItem.search(saved: 42)
-
- results = search.results
- custom_fields = results.map do |record|
- record.custom_field_list.custom_fields.map(&:internal_id)
- end.flatten.uniq
- [
- :location_quantity_available,
- :location_re_order_point,
- :location_quantity_on_order,
- ].each {|field| expect(custom_fields).to include(field)}
end
end
context "advanced search" do
skip "should handle search column definitions"