Sha256: 8996439b60dfca9557908512773305e468c786b5e2eac3d82c56b124ea2dce40

Contents?: true

Size: 1.75 KB

Versions: 20

Compression:

Stored size: 1.75 KB

Contents

require File.expand_path('../../test_helper', __FILE__)

module Stripe
  class OrderTest < Test::Unit::TestCase
    FIXTURE = API_FIXTURES.fetch(:order)

    should "be listable" do
      orders = Stripe::Order.list
      assert_requested :get, "#{Stripe.api_base}/v1/orders"
      assert orders.data.kind_of?(Array)
      assert orders.first.kind_of?(Stripe::Order)
    end

    should "be retrievable" do
      order = Stripe::Order.retrieve(FIXTURE[:id])
      assert_requested :get, "#{Stripe.api_base}/v1/orders/#{FIXTURE[:id]}"
      assert order.kind_of?(Stripe::Order)
    end

    should "be creatable" do
      order = Stripe::Order.create(
        currency: "USD"
      )
      assert_requested :post, "#{Stripe.api_base}/v1/orders"
      assert order.kind_of?(Stripe::Order)
    end

    should "be saveable" do
      order = Stripe::Order.retrieve(FIXTURE[:id])
      order.metadata['key'] = 'value'
      order.save
      assert_requested :post, "#{Stripe.api_base}/v1/orders/#{FIXTURE[:id]}"
    end

    should "be updateable" do
      order = Stripe::Order.update(FIXTURE[:id], metadata: { key: 'value' })
      assert_requested :post, "#{Stripe.api_base}/v1/orders/#{FIXTURE[:id]}"
      assert order.kind_of?(Stripe::Order)
    end

    context "#pay" do
      should "pay an order" do
        order = Stripe::Order.retrieve(FIXTURE[:id])
        order = order.pay(token: API_FIXTURES.fetch(:token)[:id])
        assert order.kind_of?(Stripe::Order)
      end
    end

    context "#return_order" do
      should "return an order" do
        order = Stripe::Order.retrieve(FIXTURE[:id])
        order = order.return_order(:orders => [
          { parent: API_FIXTURES.fetch(:sku)[:id] }
        ])
        assert order.kind_of?(Stripe::OrderReturn)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
stripe-3.0.3 test/stripe/order_test.rb
stripe-3.0.1 test/stripe/order_test.rb
stripe-3.0.0 test/stripe/order_test.rb
stripe-2.12.0 test/stripe/order_test.rb
stripe-2.11.0 test/stripe/order_test.rb
stripe-2.10.0 test/stripe/order_test.rb
stripe-2.9.0 test/stripe/order_test.rb
stripe-2.8.0 test/stripe/order_test.rb
stripe-2.7.0 test/stripe/order_test.rb
stripe-2.6.0 test/stripe/order_test.rb
stripe-2.5.0 test/stripe/order_test.rb
stripe-2.4.0 test/stripe/order_test.rb
stripe-2.3.0 test/stripe/order_test.rb
stripe-2.2.1 test/stripe/order_test.rb
stripe-2.2.0 test/stripe/order_test.rb
stripe-2.1.0 test/stripe/order_test.rb
stripe-2.0.3 test/stripe/order_test.rb
stripe-2.0.2 test/stripe/order_test.rb
stripe-2.0.1 test/stripe/order_test.rb
stripe-2.0.0 test/stripe/order_test.rb