Skip to content

Commit

Permalink
Add #orders to Debtor
Browse files Browse the repository at this point in the history
  • Loading branch information
anderslemke committed Feb 11, 2014
1 parent fb75008 commit 04e0e64
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/economic/debtor.rb
Expand Up @@ -72,6 +72,11 @@ def invoices
@invoices ||= DebtorProxy.new(self).get_invoices(self.handle)
end

def orders
return [] if self.handle.empty?
@orders ||= DebtorProxy.new(self).get_orders(self.handle)
end

protected

def fields
Expand Down
13 changes: 13 additions & 0 deletions spec/economic/debtor_spec.rb
Expand Up @@ -69,6 +69,19 @@
end
end

describe ".orders" do
it "return nothing if no handle" do
expect(subject.orders).to be_empty
end
it "returns invoices if there is a handle" do
mock_request('Debtor_GetOrders', {"debtorHandle"=>{"Number"=>1}}, :success)
subject.handle = Economic::Entity::Handle.new({:number => "1"})
subject.orders.each do |i|
expect(i).to be_instance_of(Economic::Order)
end
end
end

describe ".contacts" do
it "returns a DebtorContactProxy" do
expect(subject.contacts).to be_instance_of(Economic::DebtorContactProxy)
Expand Down

0 comments on commit 04e0e64

Please sign in to comment.