Skip to content

Commit

Permalink
Updates for PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
karmakaze committed Nov 21, 2019
1 parent b941411 commit 702b858
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions lib/shopify_api/resources/fulfillment_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module ShopifyAPI
class FulfillmentOrder < Base
def self.all(options = {})
order_id = options.dig(:params, :order_id)
raise ShopifyAPI::ValidationException, "'order_id' is required" if order_id.nil? || order_id == ''

order = ::ShopifyAPI::Order.new(id: order_id)
order.fulfillment_orders
end
Expand Down
8 changes: 4 additions & 4 deletions test/assigned_fulfillment_order_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
class AssignedFulFillmentOrderTest < Test::Unit::TestCase
context "AssignedFulfillmentOrder" do
context "#all" do
should "be able to list assigned fulfillment orders by assigned_status" do
should "list assigned fulfillment orders by assigned_status" do
fo_fixture = load_fixture('assigned_fulfillment_orders')
fake 'assigned_fulfillment_orders.json?assigned_status=cancellation_requested', method: :get,
body: fo_fixture, extension: false

assigned_fulfillment_orders = ShopifyAPI::AssignedFulfillmentOrder.all(
params: { assigned_status: 'cancellation_requested' }
params: { assigned_status: ShopifyAPI::AssignedFulfillmentOrder::CANCELLATION_REQUESTED }
)

assert_equal 2, assigned_fulfillment_orders.count
assigned_fulfillment_orders.each do |fulfillment_order|
assert_equal 'ShopifyAPI::FulfillmentOrder', fulfillment_order.class.name
assert_equal 'open', fulfillment_order.status
assert_equal 'unsubmitted', fulfillment_order.request_status
assert_equal 'in_progress', fulfillment_order.status
assert_equal 'cancellation_accepted', fulfillment_order.request_status
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/assigned_fulfillment_orders.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"id": 519788021,
"order_id": 450789469,
"fulfillment_service_handle": "shipwire",
"status": "open",
"status": "in_progress",
"requires_shipping": true,
"is_not_deleted": true,
"deleted_at": null,
"created_at": "2016-07-12T11:23:42-04:00",
"updated_at": "2016-07-12T11:23:42-04:00",
"happened_at": "2016-07-12T11:23:42-04:00",
"assigned_location_id": 905684977,
"request_status": "unsubmitted",
"request_status": "cancellation_accepted",
"delivery_category": null,
"fulfillment_order_line_items": [
{
Expand Down Expand Up @@ -41,15 +41,15 @@
"id": 519788022,
"order_id": 450789469,
"fulfillment_service_handle": "manual",
"status": "open",
"status": "in_progress",
"requires_shipping": true,
"is_not_deleted": true,
"deleted_at": null,
"created_at": "2016-07-12T11:23:42-04:00",
"updated_at": "2016-07-12T11:23:42-04:00",
"happened_at": "2016-07-12T11:23:42-04:00",
"assigned_location_id": 905684977,
"request_status": "unsubmitted",
"request_status": "cancellation_accepted",
"delivery_category": null,
"fulfillment_order_line_items": [
{
Expand Down
9 changes: 7 additions & 2 deletions test/fulfillment_order_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ def setup
params: { order_id: 450789469 }
)

assert_equal 2, fulfillment_orders.count
assert_equal [519788021, 519788022], fulfillment_orders.map(&:id).sort
fulfillment_orders.each do |fulfillment_order|
assert_equal 'ShopifyAPI::FulfillmentOrder', fulfillment_order.class.name
assert_equal 450789469, fulfillment_order.order_id
end
assert_equal [519788021, 519788022], fulfillment_orders.map(&:id).sort
end

should "require order_id" do
assert_raises ShopifyAPI::ValidationException do
ShopifyAPI::FulfillmentOrder.all
end
end
end

Expand Down
3 changes: 1 addition & 2 deletions test/order_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ class OrderTest < Test::Unit::TestCase
fake 'orders/450789469/fulfillment_orders', method: :get, body: load_fixture('fulfillment_orders')
fulfillment_orders = order.fulfillment_orders

assert_equal 2, fulfillment_orders.count
assert_equal [519788021, 519788022], fulfillment_orders.map(&:id).sort
fulfillment_orders.each do |fulfillment_order|
assert_equal 'ShopifyAPI::FulfillmentOrder', fulfillment_order.class.name
assert_equal 450789469, fulfillment_order.order_id
end
assert_equal [519788021, 519788022], fulfillment_orders.map(&:id).sort
end
end

0 comments on commit 702b858

Please sign in to comment.