Sha256: c4a930845e16d302fee5fccdcaeb37a8b1fbbfae35225898f3231bb3ac365899

Contents?: true

Size: 1.61 KB

Versions: 20

Compression:

Stored size: 1.61 KB

Contents

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

module Stripe
  class OrderTest < Test::Unit::TestCase
    should "be listable" do
      orders = Stripe::Order.list
      assert_requested :get, "#{Stripe.api_base}/v1/orders"
      assert orders.data.is_a?(Array)
      assert orders.first.is_a?(Stripe::Order)
    end

    should "be retrievable" do
      order = Stripe::Order.retrieve("or_123")
      assert_requested :get, "#{Stripe.api_base}/v1/orders/or_123"
      assert order.is_a?(Stripe::Order)
    end

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

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

    should "be updateable" do
      order = Stripe::Order.update("or_123", metadata: { key: "value" })
      assert_requested :post, "#{Stripe.api_base}/v1/orders/or_123"
      assert order.is_a?(Stripe::Order)
    end

    context "#pay" do
      should "pay an order" do
        order = Stripe::Order.retrieve("or_123")
        order = order.pay(token: "tok_123")
        assert order.is_a?(Stripe::Order)
      end
    end

    context "#return_order" do
      should "return an order" do
        order = Stripe::Order.retrieve("or_123")
        order = order.return_order(orders: [
          { parent: "sku_123" },
        ])
        assert order.is_a?(Stripe::OrderReturn)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
stripe-3.14.0 test/stripe/order_test.rb
stripe-3.13.1 test/stripe/order_test.rb
stripe-3.13.0 test/stripe/order_test.rb
stripe-3.12.1 test/stripe/order_test.rb
stripe-3.12.0 test/stripe/order_test.rb
stripe-3.11.0 test/stripe/order_test.rb
stripe-3.10.0 test/stripe/order_test.rb
stripe-3.9.2 test/stripe/order_test.rb
stripe-3.9.1 test/stripe/order_test.rb
stripe-3.9.0 test/stripe/order_test.rb
stripe-3.8.2 test/stripe/order_test.rb
stripe-3.8.1 test/stripe/order_test.rb
stripe-3.8.0 test/stripe/order_test.rb
stripe-3.7.0 test/stripe/order_test.rb
stripe-3.6.0 test/stripe/order_test.rb
stripe-3.5.3 test/stripe/order_test.rb
stripe-3.5.2 test/stripe/order_test.rb
stripe-3.5.1 test/stripe/order_test.rb
stripe-3.5.0 test/stripe/order_test.rb
stripe-3.4.1 test/stripe/order_test.rb