Sha256: 5a67d156ec5dc366aa9ee32ce9d1f2b793a2d6a4de2a985218c298daa73444ea

Contents?: true

Size: 1.88 KB

Versions: 17

Compression:

Stored size: 1.88 KB

Contents

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

module Stripe
  class ChargeRefundTest < Test::Unit::TestCase
    should "refunds should be listable" do
      @mock.expects(:get).once.returns(make_response(make_charge))

      charge = Stripe::Charge.retrieve('test_charge')

      assert charge.refunds.first.kind_of?(Stripe::Refund)
    end

    should "refunds should be refreshable" do
      @mock.expects(:get).twice.returns(make_response(make_charge), make_response(make_refund(:id => 'refreshed_refund')))

      charge = Stripe::Charge.retrieve('test_charge')
      refund = charge.refunds.first
      refund.refresh

      assert_equal 'refreshed_refund', refund.id
    end

    should "refunds should be updateable" do
      @mock.expects(:get).
        with("#{Stripe.api_base}/v1/charges/test_charge", nil, nil).
        once.returns(make_response(make_charge))
      @mock.expects(:post).
        with("#{Stripe.api_base}/v1/refunds/ref_test_refund", nil, 'metadata[key]=value').
        once.returns(make_response(make_refund(:metadata => {'key' => 'value'})))

      charge = Stripe::Charge.retrieve('test_charge')
      refund = charge.refunds.first

      assert_equal nil, refund.metadata['key']

      refund.metadata['key'] = 'value'
      refund.save

      assert_equal 'value', refund.metadata['key']
    end

    should "create should return a new refund" do
      @mock.expects(:get).
        with("#{Stripe.api_base}/v1/charges/test_charge", nil, nil).
        once.returns(make_response(make_charge(:id => 'test_charge')))
      @mock.expects(:post).
        with("#{Stripe.api_base}/v1/charges/test_charge/refunds", nil, 'amount=20').
        once.returns(make_response(make_refund(:id => 'test_new_refund')))

      charge = Stripe::Charge.retrieve('test_charge')
      refund = charge.refunds.create(:amount => 20)
      assert_equal 'test_new_refund', refund.id
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
stripe-1.33.0 test/stripe/charge_refund_test.rb
stripe-1.32.1 test/stripe/charge_refund_test.rb
stripe-1.32.0 test/stripe/charge_refund_test.rb
stripe-1.31.0 test/stripe/charge_refund_test.rb
stripe-1.30.3 test/stripe/charge_refund_test.rb
stripe-1.30.2 test/stripe/charge_refund_test.rb
stripe-1.30.1 test/stripe/charge_refund_test.rb
stripe-1.30.0 test/stripe/charge_refund_test.rb
stripe-1.29.1 test/stripe/charge_refund_test.rb
stripe-1.29.0 test/stripe/charge_refund_test.rb
stripe-1.28.1 test/stripe/charge_refund_test.rb
stripe-1.28.0 test/stripe/charge_refund_test.rb
stripe-1.27.2 test/stripe/charge_refund_test.rb
stripe-1.27.1 test/stripe/charge_refund_test.rb
stripe-1.27.0 test/stripe/charge_refund_test.rb
stripe-1.26.0 test/stripe/charge_refund_test.rb
stripe-1.25.0 test/stripe/charge_refund_test.rb