Sha256: b102faf7d4fb3ce3050cde0e82db8ddf9441c921bbb4500b9e27b39c13ac3bf6

Contents?: true

Size: 1.65 KB

Versions: 62

Compression:

Stored size: 1.65 KB

Contents

require 'test_helper'

module Workarea
  class Payment
    class Refund
      class CreditCardTest < Workarea::TestCase
        def test_complete_raises_if_the_reference_transaction_is_blank
          transaction.reference = nil
          operation = Payment::Refund::CreditCard.new(payment.credit_card, transaction)

          assert_raises(Payment::MissingReference) { operation.complete! }
        end

        def test_complete_sets_the_response_on_the_transaction
          operation = Payment::Refund::CreditCard.new(payment.credit_card, transaction)
          operation.complete!

          assert_instance_of(
            ActiveMerchant::Billing::Response,
            transaction.response
          )
        end

        private

        def authorization
          @authorization ||= ActiveMerchant::Billing::BogusGateway::AUTHORIZATION
        end

        def payment
          @payment ||=
            begin
              result = create_payment
              result.set_credit_card(
                number: 1,
                month: 1,
                year: Time.current.year + 1,
                cvv: 999
              )

              result
            end
        end

        def reference
          @reference ||= Transaction.new(
            amount: 5.to_m,
            response: ActiveMerchant::Billing::Response.new(
              true,
              'Message',
              {},
              { authorization: authorization }
            )
          )
        end

        def transaction
          @transaction ||= payment.credit_card.build_transaction(
            amount: 5.to_m,
            reference: reference
          )
        end
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.5.26 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.4.45 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.5.25 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.5.23 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.4.44 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.5.22 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.4.43 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.5.21 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.4.42 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.5.20 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.4.41 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.5.19 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.4.40 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.5.18 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.4.39 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.5.17 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.4.38 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.5.16 test/models/workarea/payment/refund/credit_card_test.rb
workarea-core-3.4.37 test/models/workarea/payment/refund/credit_card_test.rb