Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Commit

Permalink
Add OrderCollection.get
Browse files Browse the repository at this point in the history
  • Loading branch information
allolex committed May 21, 2014
1 parent 0751d87 commit d2ec13f
Show file tree
Hide file tree
Showing 3 changed files with 1,959 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/nacre/order_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

module Nacre

class OrderCollection
class OrderCollection < AbstractCollection

include Enumerable

extend Inflectible
extend Getable

attr_accessor :members

Expand Down Expand Up @@ -36,6 +36,10 @@ def self.from_json(json)

private

def self.service_name
'order'
end

def self.extract_orders(json)
JSON.parse(json)['response']
end
Expand Down
42 changes: 42 additions & 0 deletions spec/lib/nacre/order_collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,46 @@
end
end
end

describe '.get' do

let(:range) { '990071,990294,990458,990595,991847' }

let(:get_options) do
{
search_url: order_service_url,
ids: range,
options: [
'customFields',
'nullCustomFields'
]
}
end

before do
@url = Nacre::RequestUrl.new(get_options)
stub_request(
:get,
@url.to_s
).to_return(
status: 200,
body: fixture_file_content('orders_collection.json'),
headers: {}
)
@collection = described_class.get(range)
end


it 'should query the API server' do
expect(a_request(:get, @url.to_s)).to have_been_made
end

it 'should return a valid OrderCollection' do
expect(@collection).to be_a(Nacre::OrderCollection)
end

it 'should contain the fixture orders' do
expect(@collection.first).to be_a(Nacre::Order)
end
end
end
Loading

0 comments on commit d2ec13f

Please sign in to comment.