Sha256: 325ace1ff093888c50d0b1e81457efdff00e1a348bc05dc608335dc34b8c9076

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

require 'test_helper'

module Workarea
  class KlarnaPaymentTest < TestCase
    setup :configure_klarna_data

    def test_set_klarna
      payment = Payment.new

      assert_nil(payment.klarna)

      payment.set_klarna(
        authorization_token: '234',
        authorization_token_expires_at: 1.hour.from_now,
        payment_method_category: 'pay_later',
        amount: 10000000.to_m
      )

      assert(payment.klarna.present?)
      assert_equal('234', payment.klarna.authorization_token)
      assert(payment.klarna.authorization_token_expires_at.present?)
      assert_equal('pay_later', payment.klarna.payment_method_category)
      assert_equal(0.to_m, payment.klarna.amount)

      payment.clear_klarna
      assert_nil(payment.klarna)
    end

    def test_eligible_for_klarna?
      payment = Payment.new

      refute(payment.eligible_for_klarna?)

      payment.build_address(unsupported_address)

      assert(payment.address.valid?)
      refute(payment.eligible_for_klarna?)

      payment.address.attributes = supported_eur_address

      assert(payment.address.valid?)
      assert(payment.eligible_for_klarna?)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workarea-klarna-1.1.0 test/models/workarea/klarna_payment_test.rb
workarea-klarna-1.1.0.beta1 test/models/workarea/klarna_payment_test.rb
workarea-klarna-1.0.0 test/models/workarea/klarna_payment_test.rb
workarea-klarna-1.0.0.beta2 test/models/workarea/klarna_payment_test.rb
workarea-klarna-1.0.0.beta1 test/models/workarea/klarna_payment_test.rb