Sha256: 1a8df1590bd2bc2cd618cb24225723fb26ef7944396727cc2885f30684b22ee4

Contents?: true

Size: 1.97 KB

Versions: 8

Compression:

Stored size: 1.97 KB

Contents

# frozen_string_literal: true
require 'test_helper'

class FulFillmentEventTest < Test::Unit::TestCase
  def test_find_all_resources
    fake(
      'orders/450789469/fulfillments/255858046/events',
      method: :get,
      body: "[#{load_fixture('fulfillment_event')}]"
    )
    events = ShopifyAPI::FulfillmentEvent.all(
      params: { fulfillment_id: 255858046, order_id: 450789469 }
    )

    assert_equal(1, events.count)
  end

  def test_find_a_resource
    fake(
      'orders/450789469/fulfillments/255858046/events/334455',
      method: :get,
      body: load_fixture('fulfillment_event')
    )
    event = ShopifyAPI::FulfillmentEvent.find(
      334455, params: { fulfillment_id: 255858046, order_id: 450789469 }
    )

    assert_equal('in_transit', event.status)
    assert_equal(255858046, event.fulfillment_id)
    assert_equal(450789469, event.order_id)
  end

  def test_create_a_resource
    fake('orders/450789469/fulfillments/255858046/events', method: :post, body: '')

    event = ShopifyAPI::FulfillmentEvent.new(
      fulfillment_id: 255858046,
      order_id: 450789469,
      status: 'in_transit'
    )

    assert(event.save)
  end

  def test_update_a_resource
    fake(
      'orders/450789469/fulfillments/255858046/events/334455',
      method: :get,
      body: load_fixture('fulfillment_event')
    )
    event = ShopifyAPI::FulfillmentEvent.find(
      334455, params: { fulfillment_id: 255858046, order_id: 450789469 }
    )

    fake('orders/450789469/fulfillments/255858046/events/334455', method: :put, body: '')

    assert(event.save)
  end

  def test_destroy_a_resource
    fake(
      'orders/450789469/fulfillments/255858046/events/334455',
      method: :get,
      body: load_fixture('fulfillment_event')
    )
    event = ShopifyAPI::FulfillmentEvent.find(
      334455, params: { fulfillment_id: 255858046, order_id: 450789469 }
    )

    fake('orders/450789469/fulfillments/255858046/events/334455', method: :delete, body: '')

    assert(event.destroy)
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
ruby_shopify_api-1.2.0 test/fulfillment_event_test.rb
ruby_shopify_api-1.1.0 test/fulfillment_event_test.rb
ruby_shopify_api-1.0.0 test/fulfillment_event_test.rb
shopify_api-9.5.1 test/fulfillment_event_test.rb
shopify_api-9.5 test/fulfillment_event_test.rb
shopify_api-9.4.1 test/fulfillment_event_test.rb
shopify_api-9.4.0 test/fulfillment_event_test.rb
shopify_api-9.3.0 test/fulfillment_event_test.rb