Sha256: ac59267d3cdfb9cb80fe71f5caaa5361ae1895257b96b92542056f24e1187189

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

require 'test_helper'

class TestPinRefund < MiniTest::Unit::TestCase
  def setup
    common_setup
    FakeWeb.register_uri(:post, 'https://test-api.pin.net.au/1/charges', body: fixtures['responses']['charge']['success'])
    @charge = PinPayment::Charge.create(charge_hash)
  end

  def test_duplicate_refund
    FakeWeb.register_uri(:post, "https://test-api.pin.net.au/1/charges/#{@charge.token}/refunds", body: fixtures['responses']['refund']['success'])
    PinPayment::Refund.create(@charge)
    FakeWeb.register_uri(:post, "https://test-api.pin.net.au/1/charges/#{@charge.token}/refunds", body: fixtures['responses']['refund']['duplicate'])
    assert_raises PinPayment::Error::InvalidResource do
      PinPayment::Refund.create(@charge)
    end
  end

  def test_direct_refund
    FakeWeb.register_uri(:post, "https://test-api.pin.net.au/1/charges/#{@charge.token}/refunds", body: fixtures['responses']['refund']['success'])
    refund = PinPayment::Refund.create(@charge.token)
    assert_equal 'Pending', refund.status
  end

  def test_object_refund
    FakeWeb.register_uri(:post, "https://test-api.pin.net.au/1/charges/#{@charge.token}/refunds", body: fixtures['responses']['refund']['success'])
    refund = @charge.refund!
    assert_equal 'Pending', refund.status
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pin_payment-0.5.2 test/test_pin_refund.rb
pin_payment-0.5.1 test/test_pin_refund.rb
pin_payment-0.5.0 test/test_pin_refund.rb
pin_payment-0.4.0 test/test_pin_refund.rb
pin_payment-0.3.0 test/test_pin_refund.rb
pin_payment-0.2.0 test/test_pin_refund.rb
pin_payment-0.1.0 test/test_pin_refund.rb