fulfillment_request_test.rb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # frozen_string_literal: true
  2. require 'test_helper'
  3. class FulFillmentRequestTest < Test::Unit::TestCase
  4. def setup
  5. super
  6. fake("orders/450789469/fulfillment_requests/695890229", method: :get, body: load_fixture('fulfillment_request'))
  7. end
  8. context "#mark_as_failed" do
  9. should "be able to mark_as_failed a fulfillment request" do
  10. fulfillment_request = ShopifyAPI::FulfillmentRequest.find(695890229, params: { order_id: 450789469 })
  11. cancelled = ActiveSupport::JSON.decode(load_fixture('fulfillment_request'))
  12. cancelled['failure_message'] = 'failure reason'
  13. cancelled['message'] = nil
  14. fake(
  15. "orders/450789469/fulfillment_requests/695890229/mark_as_failed",
  16. method: :put,
  17. body: ActiveSupport::JSON.encode(cancelled)
  18. )
  19. assert(fulfillment_request.failure_message.blank?)
  20. assert(fulfillment_request.mark_as_failed)
  21. assert_equal('failure reason', fulfillment_request.failure_message)
  22. end
  23. end
  24. context "#find" do
  25. should "be able to find fulfillment request" do
  26. fulfillment_request = ShopifyAPI::FulfillmentRequest.find(695890229, params: { order_id: 450789469 })
  27. assert_equal(695890229, fulfillment_request.id)
  28. assert_equal(450789469, fulfillment_request.order_id)
  29. end
  30. end
  31. end