fulfillment_test.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. require 'test_helper'
  2. class FulFillmentTest < Test::Unit::TestCase
  3. def setup
  4. fake "orders/450789469/fulfillments/255858046", :method => :get, :body => load_fixture('fulfillment')
  5. end
  6. context "Fulfillment" do
  7. context "#complete" do
  8. should "be able to complete fulfillment" do
  9. fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => {:order_id => 450789469})
  10. success = ActiveSupport::JSON.decode(load_fixture('fulfillment'))
  11. success['fulfillment']['status'] = 'success'
  12. fake "orders/450789469/fulfillments/255858046/complete", :method => :post, :body => ActiveSupport::JSON.encode(success)
  13. assert_equal 'pending', fulfillment.status
  14. assert fulfillment.complete
  15. assert_equal 'success', fulfillment.status
  16. end
  17. end
  18. context "#cancel" do
  19. should "be able to cancel fulfillment" do
  20. fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => {:order_id => 450789469})
  21. cancelled = ActiveSupport::JSON.decode(load_fixture('fulfillment'))
  22. cancelled['fulfillment']['status'] = 'cancelled'
  23. fake "orders/450789469/fulfillments/255858046/cancel", :method => :post, :body => ActiveSupport::JSON.encode(cancelled)
  24. assert_equal 'pending', fulfillment.status
  25. assert fulfillment.cancel
  26. assert_equal 'cancelled', fulfillment.status
  27. end
  28. end
  29. end
  30. end