Skip to content

Commit

Permalink
divisions orders endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
one-m1nd committed Feb 28, 2024
1 parent cf4b312 commit 34b9e3c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/plants/resources.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'plants/resources/division_classes'
require 'plants/resources/division_orders'
require 'plants/resources/divisions'
require 'plants/resources/families'
require 'plants/resources/genus'
Expand All @@ -10,6 +11,7 @@ module Plants
# Resources 'container' module
module Resources
include DivisionClasses
include DivisionOrders
include Divisions
include Families
include Genus
Expand Down
19 changes: 19 additions & 0 deletions lib/plants/resources/division_orders.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Plants
module Resources
# Division orders module
# @see https://docs.trefle.io/reference#tag/DivisionOrders
module DivisionOrders
# GET /division_orders
# @return [::HTTP::Response]
def list_division_orders
client.get('division_orders')
end

# @param division_order [String]
# @return [::HTTP::Response]
def find_division_order(division_order)
client.get("division_orders/#{division_order}")
end
end
end
end
28 changes: 28 additions & 0 deletions spec/plants_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,32 @@
expect(a_request(:get, "#{Plants::Client::URL}/division_classes/foobar")).to have_been_made
end
end

describe '.list_division_orders' do
before(:each) do
stub_request(:get, "#{Plants::Client::URL}/division_orders")
.to_return(status: 200, body: '{}')
end

subject { Plants.list_division_orders }

it do
expect(subject).to be_instance_of(HTTP::Response)
expect(a_request(:get, "#{Plants::Client::URL}/division_orders")).to have_been_made
end
end

describe '.find_division_order' do
before(:each) do
stub_request(:get, "#{Plants::Client::URL}/division_orders/foobar")
.to_return(status: 200, body: '{}')
end

subject { Plants.find_division_order('foobar') }

it do
expect(subject).to be_instance_of(HTTP::Response)
expect(a_request(:get, "#{Plants::Client::URL}/division_orders/foobar")).to have_been_made
end
end
end

0 comments on commit 34b9e3c

Please sign in to comment.