Sha256: ec71449ccecd6e858d612c249304161b678f968d5b2e7445abd6c9cee6f4e239

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

module Workarea
  decorate Payment::Authorize::CreditCardTest, with: :cyber_source do
    def test_complete_does_nothing_if_gateway_storage_fails
      # cyber_source authorizes and tokenizes in one call; nullifying this test
    end

    def test_cancel_voids_with_the_authorization_from_the_transaction
      transaction.response = ActiveMerchant::Billing::Response.new(
        true,
        'Message',
        {},
        { authorization:  authorization }
      )

      operation = Payment::Authorize::CreditCard.new(tender, transaction)

      original_void = operation.gateway.method(:void)
      operation.gateway.expects(:void)
        .with(authorization)
        .returns(original_void.call(authorization))

      operation.cancel!
    end

    def test_cancel_sets_cancellation_params_on_the_transaction
      transaction.response = ActiveMerchant::Billing::Response.new(
        true,
        'Message',
        {},
        { authorization: authorization }
      )

      operation = Payment::Authorize::CreditCard.new(tender, transaction)
      operation.cancel!

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

    private

    def tender
      @tender ||=
        begin
          payment.set_address(
            first_name: 'Ben',
            last_name: 'Crouse',
            street: '22 s 3rd st',
            city: 'Philadelphia',
            region: 'PA',
            country: Country['US'],
            postal_code: '19106'
          )

          payment.build_credit_card(
            number: 4111111111111111,
            month: 1,
            year: Time.now.year + 1,
            cvv: 999
          )

          payment.credit_card
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-cyber_source-1.0.3 test/models/workarea/payment/authorize/credit_card_test.decorator