Sha256: ec453b1ffc8fac7a8a4f33b6dc279ea12407a8c69be5525f5aa942cd34260379

Contents?: true

Size: 1.64 KB

Versions: 23

Compression:

Stored size: 1.64 KB

Contents

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

module Stripe
  class OrderTest < Test::Unit::TestCase
    should "orders should be listable" do
      @mock.expects(:get).once.returns(make_response(make_order_array))
      orders = Stripe::Order.list
      assert orders.data.kind_of?(Array)
      orders.each do |order|
        assert order.kind_of?(Stripe::Order)
      end
    end

    should "orders should not be deletable" do
      assert_raises NoMethodError do
        @mock.expects(:get).once.returns(make_response(make_order))
        p = Stripe::Order.retrieve("test_order")
        p.delete
      end
    end

    should "orders should be updateable" do
      @mock.expects(:get).once.returns(make_response(make_order))
      @mock.expects(:post).once.returns(make_response(make_order))
      p = Stripe::Order.new("test_order")
      p.refresh
      p.status = "fulfilled"
      p.save
    end

    should "orders should allow metadata updates" do
      @mock.expects(:get).once.returns(make_response(make_order))
      @mock.expects(:post).once.returns(make_response(make_order))
      p = Stripe::Order.new("test_order")
      p.refresh
      p.metadata['key'] = 'value'
      p.save
    end

    should "pay should pay an order" do
      @mock.expects(:get).once.
        returns(make_response(make_order(:id => 'or_test_order')))
      order = Stripe::Order.retrieve('or_test_order')

      @mock.expects(:post).once.
        with('https://api.stripe.com/v1/orders/or_test_order/pay', nil, 'token=test_token').
        returns(make_response(make_paid_order))
      order.pay(:token => 'test_token')
      assert_equal "paid", order.status
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
stripe-1.42.0 test/stripe/order_test.rb
stripe-1.41.0 test/stripe/order_test.rb
stripe-1.40.0 test/stripe/order_test.rb
stripe-1.39.0 test/stripe/order_test.rb
stripe-1.38.0 test/stripe/order_test.rb
stripe-1.37.0 test/stripe/order_test.rb
stripe-1.36.2 test/stripe/order_test.rb
stripe-1.36.1 test/stripe/order_test.rb
stripe-1.36.0 test/stripe/order_test.rb
stripe-1.35.1 test/stripe/order_test.rb
stripe-1.35.0 test/stripe/order_test.rb
stripe-1.34.0 test/stripe/order_test.rb
stripe-1.33.1 test/stripe/order_test.rb
stripe-1.33.0 test/stripe/order_test.rb
stripe-1.32.1 test/stripe/order_test.rb
stripe-1.32.0 test/stripe/order_test.rb
stripe-1.31.0 test/stripe/order_test.rb
stripe-1.30.3 test/stripe/order_test.rb
stripe-1.30.2 test/stripe/order_test.rb
stripe-1.30.1 test/stripe/order_test.rb