Skip to content

Commit

Permalink
Disable FulfillmentOrder.all call instead of supporting it wirh order…
Browse files Browse the repository at this point in the history
…_id param
  • Loading branch information
linzhao125 committed Jan 9, 2020
1 parent e3eeb3b commit 50bd958
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
10 changes: 5 additions & 5 deletions lib/shopify_api/resources/fulfillment_order.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module ShopifyAPI
class FulfillmentOrder < Base
def self.find(scope, *args)
order_id = args.first&.dig(:params, :order_id)
raise ShopifyAPI::ValidationException, "'order_id' is required" if order_id.blank?

order = ::ShopifyAPI::Order.new(id: order_id)
order.fulfillment_orders(args.first[:params].except(:order_id))
class OperationNotSupported < StandardError
end

def self.all
raise OperationNotSupported, "ShopifyAPI::FulfillmentOrder.all operation is not supported. "
end

def fulfillments(options = {})
Expand Down
19 changes: 3 additions & 16 deletions test/fulfillment_order_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,12 @@ def setup
assert_equal 519788021, fulfillment_order.id
assert_equal 450789469, fulfillment_order.order_id
end

end

context "#all" do
should "be able to list fulfillment orders for an order" do
fake 'orders/450789469/fulfillment_orders', method: :get, body: load_fixture('fulfillment_orders')

fulfillment_orders = ShopifyAPI::FulfillmentOrder.all(
params: { order_id: 450789469 }
)

assert_equal [519788021, 519788022], fulfillment_orders.map(&:id).sort
fulfillment_orders.each do |fulfillment_order|
assert fulfillment_order.is_a?(ShopifyAPI::FulfillmentOrder)
assert_equal 450789469, fulfillment_order.order_id
end
end

should "require order_id" do
assert_raises ShopifyAPI::ValidationException do
should "should raise OperationNotSupported error" do
assert_raises ShopifyAPI::FulfillmentOrder::OperationNotSupported do
ShopifyAPI::FulfillmentOrder.all
end
end
Expand Down

0 comments on commit 50bd958

Please sign in to comment.