require 'test_helper' class FulFillmentOrderTest < Test::Unit::TestCase def setup super fake "fulfillment_orders/519788021", method: :get, body: load_fixture('fulfillment_order') fake "orders/450789469/fulfillment_orders", method: :get, body: load_fixture('fulfillment_orders') end context "FulfillmentOrder" do context "#find" do should "be able to find fulfillment order" do fulfillment_order = ShopifyAPI::FulfillmentOrder.find(519788021) assert fulfillment_order.is_a?(ShopifyAPI::FulfillmentOrder) 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 ShopifyAPI::FulfillmentOrder.all end end end context "#fulfillments" do should "be able to list fulfillments for a fulfillment order" do fulfillment_order = ShopifyAPI::FulfillmentOrder.find(519788021) fake "fulfillment_orders/#{fulfillment_order.id}/fulfillments", method: :get, body: load_fixture('fulfillments') fulfillments = fulfillment_order.fulfillments assert_equal 1, fulfillments.count fulfillment = fulfillments.first assert fulfillment.is_a?(ShopifyAPI::Fulfillment) assert_equal 450789469, fulfillment.order_id end end end end