Sha256: 1c80e102cebf4d1394ffbc56c631d1b0d02932351a7c278e1ef0a4ef433d304f

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

require 'test_helper'

module Workarea
  decorate PaymentTest, with: :kount do
    def test_status
      order = create_order
      payment = Payment.new(
        id: order.id,
        address: {
          first_name: 'Ben',
          last_name: 'Crouse',
          street: '22 S. 3rd St.',
          street_2: 'Second Floor',
          city: 'Philadelphia',
          region: 'PA',
          postal_code: '19106',
          country: 'US',
          phone_number: '2159251800'
        }
      )

      assert_equal(:not_applicable, payment.status)

      payment.build_credit_card(
        number: '4111111111111111',
        month: 1,
        year: Time.current.year + 1,
        cvv: 999,
        amount: 10.to_m
      )

      tender = payment.credit_card
      payment.save!

      assert_equal(:pending, payment.status)

      tender.build_transaction(amount: 10.to_m, success: true, action: 'authorize').save!

      assert_equal(:authorized, payment.reload.status)

      tender.build_transaction(amount: 5.to_m, success: true, action: 'capture').save!
      assert_equal(:partially_captured, payment.reload.status)

      tender.build_transaction(amount: 5.to_m, success: true, action: 'purchase').save!
      assert_equal(:captured, payment.status)

      tender.build_transaction(amount: 5.to_m, success: true, action: 'refund').save!
      assert_equal(:partially_refunded, payment.reload.status)

      tender.build_transaction(amount: 5.to_m, success: true, action: 'refund').save!
      assert_equal(:refunded, payment.reload.status)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-kount-3.3.1 test/models/workarea/payment_test.decorator
workarea-kount-3.3.0 test/models/workarea/payment_test.decorator