forked from NetSweet/netsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b8928a
commit 7197886
Showing
3 changed files
with
280 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
require 'spec_helper' | ||
|
||
describe NetSuite::Actions::Search do | ||
before(:all) { savon.mock! } | ||
after(:all) { savon.unmock! } | ||
|
||
context "saved search" do | ||
it "should handle a ID only search" do | ||
savon.expects(:search).with(:message => { | ||
'searchRecord' => { | ||
'@xsi:type' => 'listRel:CustomerSearchAdvanced', | ||
'@savedSearchId' => 500, | ||
:content! => { "listRel:criteria" => {} } | ||
}, | ||
}).returns(File.read('spec/support/fixtures/search/saved_search_customer.xml')) | ||
|
||
result = NetSuite::Records::Customer.search(saved: 500) | ||
result.results.size.should == 1 | ||
result.results.first.email.should == '[email protected]' | ||
end | ||
|
||
it "should handle a ID search with basic params" do | ||
|
||
end | ||
|
||
it "should handle a search with joined params" do | ||
|
||
end | ||
|
||
it "should handle a search with joined params containing custom field search" do | ||
savon.expects(:search).with(:message => { | ||
'searchRecord' => { | ||
'@xsi:type' => 'listRel:CustomerSearchAdvanced', | ||
'@savedSearchId' => 500, | ||
:content! => { | ||
"listRel:criteria" => { | ||
"listRel:basic" => { | ||
"platformCommon:entityId" => { | ||
"platformCore:searchValue" => "New Keywords" | ||
}, | ||
|
||
:attributes! => { | ||
"platformCommon:entityId" => { "operator" => "hasKeywords" }, | ||
"platformCommon:stage" => { "operator" => "anyOf" } | ||
}, | ||
|
||
"platformCommon:stage" => { "platformCore:searchValue" => ["_lead", "_customer"] }, | ||
"platformCommon:customFieldList" => { | ||
"platformCore:customField" => [ | ||
{ | ||
"platformCore:searchValue" => [{}, {}], | ||
:attributes! => { | ||
"platformCore:searchValue" => { | ||
"internalId" => [4, 11] | ||
} | ||
} | ||
}, | ||
{ | ||
"platformCore:searchValue" => [{}], | ||
:attributes! => { | ||
"platformCore:searchValue" => { "internalId" => [88825] } | ||
} | ||
} | ||
], | ||
|
||
:attributes! => { | ||
"platformCore:customField" => { | ||
"internalId" => ["custentity_customerandcontacttypelist", "custentity_relatedthing"], | ||
"operator" => ["anyOf", "anyOf"], | ||
"xsi:type" => ["platformCore:SearchMultiSelectCustomField", "platformCore:SearchMultiSelectCustomField"] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
}).returns(File.read('spec/support/fixtures/search/saved_search_joined_custom_customer.xml')) | ||
|
||
search = NetSuite::Records::Customer.search({ | ||
saved: 500, | ||
basic: [ | ||
{ | ||
field: 'entityId', | ||
value: 'New Keywords', | ||
operator: 'hasKeywords' | ||
}, | ||
{ | ||
field: 'stage', | ||
operator: 'anyOf', | ||
type: 'SearchMultiSelectCustomField', | ||
value: [ | ||
'_lead', | ||
'_customer' | ||
] | ||
}, | ||
{ | ||
field: 'customFieldList', | ||
value: [ | ||
{ | ||
field: 'custentity_customerandcontacttypelist', | ||
operator: 'anyOf', | ||
# type is needed for multiselect fields | ||
type: 'SearchMultiSelectCustomField', | ||
value: [ | ||
NetSuite::Records::CustomRecordRef.new(:internal_id => 4), | ||
NetSuite::Records::CustomRecordRef.new(:internal_id => 11), | ||
] | ||
}, | ||
{ | ||
field: 'custentity_relatedthing', | ||
# is in the GUI is the equivilent of anyOf with a single element array | ||
operator: 'anyOf', | ||
type: 'SearchMultiSelectCustomField', | ||
value: [ | ||
NetSuite::Records::Customer.new(:internal_id => 88825) | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}) | ||
|
||
search.results.size.should == 2 | ||
search.results.first.alt_name.should == 'A Awesome Name' | ||
search.results.last.email.should == '[email protected]' | ||
end | ||
end | ||
|
||
context "basic search" do | ||
it "should handle searching basic fields" do | ||
|
||
end | ||
|
||
it "should handle searching with joined fields" do | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<soapenv:Header> | ||
<platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2012_1.platform.webservices.netsuite.com"> | ||
<platformMsgs:nsId>WEBSERVICES_3603434_082920139095115881624678969_4586850fc2d6</platformMsgs:nsId> | ||
</platformMsgs:documentInfo> | ||
</soapenv:Header> | ||
<soapenv:Body> | ||
<searchResponse xmlns="urn:messages_2012_1.platform.webservices.netsuite.com"> | ||
<platformCore:searchResult xmlns:platformCore="urn:core_2012_1.platform.webservices.netsuite.com"> | ||
<platformCore:status isSuccess="true"/> | ||
<platformCore:totalRecords>1</platformCore:totalRecords> | ||
<platformCore:pageSize>5</platformCore:pageSize> | ||
<platformCore:totalPages>1</platformCore:totalPages> | ||
<platformCore:pageIndex>1</platformCore:pageIndex> | ||
<platformCore:searchId>WEBSERVICES_3603434_082920139095115881624678969_4586850fc2d6</platformCore:searchId> | ||
<platformCore:searchRowList> | ||
<platformCore:searchRow xmlns:listRel="urn:relationships_2012_1.lists.webservices.netsuite.com" xsi:type="listRel:CustomerSearchRow"> | ||
<listRel:basic xmlns:platformCommon="urn:common_2012_1.platform.webservices.netsuite.com"> | ||
<platformCommon:altName> | ||
<platformCore:searchValue>A Awesome Name</platformCore:searchValue> | ||
</platformCommon:altName> | ||
<platformCommon:billCity> | ||
<platformCore:searchValue>A Great City</platformCore:searchValue> | ||
</platformCommon:billCity> | ||
<platformCommon:billState> | ||
<platformCore:searchValue>PA</platformCore:searchValue> | ||
</platformCommon:billState> | ||
<platformCommon:billZipCode> | ||
<platformCore:searchValue>19390</platformCore:searchValue> | ||
</platformCommon:billZipCode> | ||
<platformCommon:email> | ||
<platformCore:searchValue>[email protected]</platformCore:searchValue> | ||
</platformCommon:email> | ||
<platformCommon:entityId> | ||
<platformCore:searchValue>12625</platformCore:searchValue> | ||
</platformCommon:entityId> | ||
<platformCommon:phone> | ||
<platformCore:searchValue>444-444-4444</platformCore:searchValue> | ||
</platformCommon:phone> | ||
</listRel:basic> | ||
<listRel:contactJoin xmlns:platformCommon="urn:common_2012_1.platform.webservices.netsuite.com"> | ||
<platformCommon:email> | ||
<platformCore:searchValue>[email protected]</platformCore:searchValue> | ||
</platformCommon:email> | ||
<platformCommon:entityId> | ||
<platformCore:searchValue>Tony Freddo</platformCore:searchValue> | ||
</platformCommon:entityId> | ||
</listRel:contactJoin> | ||
</platformCore:searchRow> | ||
</platformCore:searchRowList> | ||
</platformCore:searchResult> | ||
</searchResponse> | ||
</soapenv:Body> | ||
</soapenv:Envelope> |
87 changes: 87 additions & 0 deletions
87
spec/support/fixtures/search/saved_search_joined_custom_customer.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<soapenv:Header> | ||
<platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2012_1.platform.webservices.netsuite.com"> | ||
<platformMsgs:nsId>WEBSERVICES_3603434_08292013908151921913870884_2f1b68b787b4d</platformMsgs:nsId> | ||
</platformMsgs:documentInfo> | ||
</soapenv:Header> | ||
<soapenv:Body> | ||
<searchResponse xmlns="urn:messages_2012_1.platform.webservices.netsuite.com"> | ||
<platformCore:searchResult xmlns:platformCore="urn:core_2012_1.platform.webservices.netsuite.com"> | ||
<platformCore:status isSuccess="true"/> | ||
<platformCore:totalRecords>2</platformCore:totalRecords> | ||
<platformCore:pageSize>1000</platformCore:pageSize> | ||
<platformCore:totalPages>1</platformCore:totalPages> | ||
<platformCore:pageIndex>1</platformCore:pageIndex> | ||
<platformCore:searchId>WEBSERVICES_3603434_08292013908151921913870884_2f1b68b787b4d</platformCore:searchId> | ||
<platformCore:searchRowList> | ||
<platformCore:searchRow xmlns:listRel="urn:relationships_2012_1.lists.webservices.netsuite.com" xsi:type="listRel:CustomerSearchRow"> | ||
<listRel:basic xmlns:platformCommon="urn:common_2012_1.platform.webservices.netsuite.com"> | ||
<platformCommon:altName> | ||
<platformCore:searchValue>A Awesome Name</platformCore:searchValue> | ||
</platformCommon:altName> | ||
<platformCommon:billCity> | ||
<platformCore:searchValue>A City</platformCore:searchValue> | ||
</platformCommon:billCity> | ||
<platformCommon:billState> | ||
<platformCore:searchValue>PA</platformCore:searchValue> | ||
</platformCommon:billState> | ||
<platformCommon:billZipCode> | ||
<platformCore:searchValue>29999</platformCore:searchValue> | ||
</platformCommon:billZipCode> | ||
<platformCommon:email> | ||
<platformCore:searchValue>[email protected]</platformCore:searchValue> | ||
</platformCommon:email> | ||
<platformCommon:entityId> | ||
<platformCore:searchValue>12625</platformCore:searchValue> | ||
</platformCommon:entityId> | ||
<platformCommon:phone> | ||
<platformCore:searchValue>444-444-4444</platformCore:searchValue> | ||
</platformCommon:phone> | ||
</listRel:basic> | ||
<listRel:contactJoin xmlns:platformCommon="urn:common_2012_1.platform.webservices.netsuite.com"> | ||
<platformCommon:email> | ||
<platformCore:searchValue>[email protected]</platformCore:searchValue> | ||
</platformCommon:email> | ||
<platformCommon:entityId> | ||
<platformCore:searchValue>Carmina</platformCore:searchValue> | ||
</platformCommon:entityId> | ||
</listRel:contactJoin> | ||
</platformCore:searchRow> | ||
<platformCore:searchRow xmlns:listRel="urn:relationships_2012_1.lists.webservices.netsuite.com" xsi:type="listRel:CustomerSearchRow"> | ||
<listRel:basic xmlns:platformCommon="urn:common_2012_1.platform.webservices.netsuite.com"> | ||
<platformCommon:altName> | ||
<platformCore:searchValue>A Less Awesome Name</platformCore:searchValue> | ||
</platformCommon:altName> | ||
<platformCommon:billCity> | ||
<platformCore:searchValue>A Less Awesome City</platformCore:searchValue> | ||
</platformCommon:billCity> | ||
<platformCommon:billState> | ||
<platformCore:searchValue>NY</platformCore:searchValue> | ||
</platformCommon:billState> | ||
<platformCommon:billZipCode> | ||
<platformCore:searchValue>19999</platformCore:searchValue> | ||
</platformCommon:billZipCode> | ||
<platformCommon:email> | ||
<platformCore:searchValue>[email protected]</platformCore:searchValue> | ||
</platformCommon:email> | ||
<platformCommon:entityId> | ||
<platformCore:searchValue>12625</platformCore:searchValue> | ||
</platformCommon:entityId> | ||
<platformCommon:phone> | ||
<platformCore:searchValue>555-555-5555</platformCore:searchValue> | ||
</platformCommon:phone> | ||
</listRel:basic> | ||
<listRel:contactJoin xmlns:platformCommon="urn:common_2012_1.platform.webservices.netsuite.com"> | ||
<platformCommon:email> | ||
<platformCore:searchValue>[email protected]</platformCore:searchValue> | ||
</platformCommon:email> | ||
<platformCommon:entityId> | ||
<platformCore:searchValue>Bill Murphy</platformCore:searchValue> | ||
</platformCommon:entityId> | ||
</listRel:contactJoin> | ||
</platformCore:searchRow> | ||
</platformCore:searchRowList> | ||
</platformCore:searchResult> | ||
</searchResponse> | ||
</soapenv:Body> | ||
</soapenv:Envelope> |