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 14, 2019
1 parent b941411 commit d4f26b4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 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
6 changes: 3 additions & 3 deletions test/assigned_fulfillment_order_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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
Expand All @@ -15,8 +15,8 @@ class AssignedFulFillmentOrderTest < Test::Unit::TestCase
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

0 comments on commit d4f26b4

Please sign in to comment.