fulfillment_event_test.rb 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # frozen_string_literal: true
  2. require 'test_helper'
  3. class FulFillmentEventTest < Test::Unit::TestCase
  4. def test_find_all_resources
  5. fake(
  6. 'orders/450789469/fulfillments/255858046/events',
  7. method: :get,
  8. body: "[#{load_fixture('fulfillment_event')}]"
  9. )
  10. events = ShopifyAPI::FulfillmentEvent.all(
  11. params: { fulfillment_id: 255858046, order_id: 450789469 }
  12. )
  13. assert_equal(1, events.count)
  14. end
  15. def test_find_a_resource
  16. fake(
  17. 'orders/450789469/fulfillments/255858046/events/334455',
  18. method: :get,
  19. body: load_fixture('fulfillment_event')
  20. )
  21. event = ShopifyAPI::FulfillmentEvent.find(
  22. 334455, params: { fulfillment_id: 255858046, order_id: 450789469 }
  23. )
  24. assert_equal('in_transit', event.status)
  25. assert_equal(255858046, event.fulfillment_id)
  26. assert_equal(450789469, event.order_id)
  27. end
  28. def test_create_a_resource
  29. fake('orders/450789469/fulfillments/255858046/events', method: :post, body: '')
  30. event = ShopifyAPI::FulfillmentEvent.new(
  31. fulfillment_id: 255858046,
  32. order_id: 450789469,
  33. status: 'in_transit'
  34. )
  35. assert(event.save)
  36. end
  37. def test_update_a_resource
  38. fake(
  39. 'orders/450789469/fulfillments/255858046/events/334455',
  40. method: :get,
  41. body: load_fixture('fulfillment_event')
  42. )
  43. event = ShopifyAPI::FulfillmentEvent.find(
  44. 334455, params: { fulfillment_id: 255858046, order_id: 450789469 }
  45. )
  46. fake('orders/450789469/fulfillments/255858046/events/334455', method: :put, body: '')
  47. assert(event.save)
  48. end
  49. def test_destroy_a_resource
  50. fake(
  51. 'orders/450789469/fulfillments/255858046/events/334455',
  52. method: :get,
  53. body: load_fixture('fulfillment_event')
  54. )
  55. event = ShopifyAPI::FulfillmentEvent.find(
  56. 334455, params: { fulfillment_id: 255858046, order_id: 450789469 }
  57. )
  58. fake('orders/450789469/fulfillments/255858046/events/334455', method: :delete, body: '')
  59. assert(event.destroy)
  60. end
  61. end