Sha256: d565fbee071c8b07cf3ba1b506e22cce16c197000da3c9d0dcf164fb32598fb8

Contents?: true

Size: 1.8 KB

Versions: 26

Compression:

Stored size: 1.8 KB

Contents

require 'test_helper'

class OrderTest < Test::Unit::TestCase

  test "create should create order" do
    fake 'orders', :method => :post, :status => 201, :body => load_fixture('order')
    order = ShopifyAPI::Order.create(line_items: [{quantity:1, variant_id:39072856}], financial_status:"authorized")
    assert_equal 39072856, order.line_items.first.variant_id
  end

  test "get should get an order" do
    fake 'orders/450789469', :method => :get, :status => 200, :body => load_fixture('order')
    order = ShopifyAPI::Order.find(450789469)
    assert_equal 450789469, order.id
  end

  test "get all should get all orders" do
    fake 'orders', :method => :get, :status => 200, :body => load_fixture('orders')
    order = ShopifyAPI::Order.all
    assert_equal 450789469, order.first.id
  end

  test "add note should add a note to order" do
    fake 'orders/450789469', :method => :get, :status => 200, :body => load_fixture('order')
    order = ShopifyAPI::Order.find(450789469)
    order.note = "Test note"
    fake 'orders/450789469', :method => :put, :status => 200, :body => load_fixture('order')
    order.save
    assert_equal "Test note", order.note
  end

  test "delete should delete an order" do
    fake 'orders/450789469', :method => :get, :status => 200, :body => load_fixture('order')
    fake 'orders/450789469', :method => :delete, :body => 'destroyed'
    order = ShopifyAPI::Order.find(450789469)
    assert order.destroy
  end

  test "cancel an order with params" do
    fake 'orders/450789469', :method => :get, :status => 200, :body => load_fixture('order')
    fake 'orders/450789469/cancel', :method => :post, :body => load_fixture('order')
    order = ShopifyAPI::Order.find(450789469)
    order.cancel(email: false, restock: true)
    assert_request_body({'email' => false, 'restock' => true}.to_json)
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
shopify_api-4.9.0 test/order_test.rb
shopify_api-4.8.0 test/order_test.rb
shopify_api-4.7.1 test/order_test.rb
shopify_api-4.7.0 test/order_test.rb
shopify_api-4.6.0 test/order_test.rb
shopify_api-4.5.0 test/order_test.rb
shopify_api-4.4.0 test/order_test.rb
shopify_api-4.3.9 test/order_test.rb
shopify_api-4.3.8 test/order_test.rb
shopify_api-4.3.7 test/order_test.rb
shopify_api-4.3.6 test/order_test.rb
shopify_api-4.3.5 test/order_test.rb
shopify_api-4.3.4 test/order_test.rb
shopify_api-4.3.3 test/order_test.rb
shopify_api-4.3.2 test/order_test.rb
shopify_api-4.3.1 test/order_test.rb
shopify_api-4.3.0 test/order_test.rb
shopify_api-4.2.2 test/order_test.rb
shopify_api-4.2.1 test/order_test.rb
shopify_api-4.2.0 test/order_test.rb