fulfillment_test.rb 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. context "#find" do
  30. should "be able to find fulfillment" do
  31. fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => {:order_id => 450789469})
  32. assert_equal 255858046, fulfillment.id
  33. assert_equal 450789469, fulfillment.order_id
  34. end
  35. end
  36. end
  37. end