Sha256: 3e29191f6b23f7cded6feb5af9e4bc958a1128efbfdf317f6e9587e746f058b0

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

require 'test_helper'

module Workarea
  class SetupKlarnaSessionTest < TestCase
    setup :configure_klarna_data

    def test_perform
      klarna_gateway_class.any_instance.expects(:create_session).never

      order = create_order
      checkout = Checkout.new(order)

      SetupKlarnaSession.new(checkout).perform

      checkout.payment.build_address(unsupported_address)
      assert(checkout.payment.address.valid?)

      SetupKlarnaSession.new(checkout).perform

      checkout.payment.address.attributes = supported_eur_address

      klarna_gateway_class
        .any_instance
        .expects(:create_session)
        .once
        .returns(OpenStruct.new(success?: true, body: { session_id: '123' }))

      SetupKlarnaSession.new(checkout).perform

      session = Payment::KlarnaSession.find(order.id)
      assert_equal('123', session.session_id)

      klarna_gateway_class
        .any_instance
        .expects(:update_session)
        .once
        .with(order, session.session_id)

      SetupKlarnaSession.new(checkout).perform
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workarea-klarna-1.1.0 test/services/workarea/setup_klarna_session_test.rb
workarea-klarna-1.1.0.beta1 test/services/workarea/setup_klarna_session_test.rb
workarea-klarna-1.0.0 test/services/workarea/setup_klarna_session_test.rb
workarea-klarna-1.0.0.beta2 test/services/workarea/setup_klarna_session_test.rb
workarea-klarna-1.0.0.beta1 test/services/workarea/setup_klarna_session_test.rb