Skip to content

Instantly share code, notes, and snippets.

@cmhobbs
Created October 23, 2012 14:18
Show Gist options
  • Save cmhobbs/3939000 to your computer and use it in GitHub Desktop.
Save cmhobbs/3939000 to your computer and use it in GitHub Desktop.
# client setup
def initialize
nconf = YAML.load_file("config/netsuite.yml")
@client = Netsuite::Client.new(nconf['account'], nconf['email'], nconf['password'], nconf['role'])
@search_id = nconf['search_id']
end
# method in question
def fetch_delayed_pos
response = @client.get_saved_search('Transaction', @search_id)
po_ids = []
response.each {|po| po_ids << po[:id]}
return po_ids
end
# this passes, but if any data is altered, it fails because the mock is ignored
it "fetches a list of POs marked as delayed" do
mock('NetSuite::Client', :get_saved_search => {:response =>
[{:id => "5054978",
:recordtype => "purchaseorder",
:columns => {:internalid => {:name => "5054978", :internalid => "5054978"},
:tranid => "PO3312702"}},
{:id => "5071519",
:recordtype =>"purchaseorder",
:columns => {:internalid => {:name => "5071519", :internalid => "5071519"},
:tranid => "PO3312843"}},
{:id => "5093002",
:recordtype => "purchaseorder",
:columns => {:internalid => {:name => "5093002", :internalid => "5093002"},
:tranid => "PO3313013"}},
{:id => "5133933",
:recordtype => "purchaseorder",
:columns => {:internalid => {:name => "5133933", :internalid => "5133933"},
:tranid => "PO3313388"}},
{:id => "5134162",
:recordtype => "purchaseorder",
:columns => {:internalid => {:name => "5134162", :internalid => "5134162"},
:tranid => "PO3313353"}},
{:id => "5183010",
:recordtype => "purchaseorder",
:columns => {:internalid => {:name => "5183010", :internalid => "5183010"},
:tranid => "PO3313793"}}]
})
c = NetsuiteConnection.new
c.fetch_delayed_pos.should == ["5054978", "5071519", "5093002", "5133933", "5134162", "5183010"]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment