Sha256: 623c83d06b446678a549cd8718d116b80e1f98668f239f6071059df12b311f19

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

require 'test_helper'

module Workarea
  class KlarnaTest < TestCase
    def test_on_site_messaging_client_id
      @_kosm_env = ENV['WORKAREA_KLARNA_ON_SITE_MESSAGING_CLIENT_ID']
      @_kosm_cred = Rails.application.credentials.klarna

      ENV['WORKAREA_KLARNA_ON_SITE_MESSAGING_CLIENT_ID'] = nil
      Rails.application.credentials.klarna = nil
      Workarea.config.klarna_on_site_messaging_client_id = nil

      assert_nil(Klarna.on_site_messaging_client_id)
      refute(Klarna.on_site_messaging?)

      Workarea.config.klarna_on_site_messaging_client_id = 'config_123'
      assert_equal('config_123', Klarna.on_site_messaging_client_id)
      assert(Klarna.on_site_messaging?)

      Rails.application.credentials.klarna = { on_site_messaging_client_id: 'cred_123' }
      assert_equal('cred_123', Klarna.on_site_messaging_client_id)
      assert(Klarna.on_site_messaging?)

      ENV['WORKAREA_KLARNA_ON_SITE_MESSAGING_CLIENT_ID'] = 'env_123'
      assert_equal('env_123', Klarna.on_site_messaging_client_id)
      assert(Klarna.on_site_messaging?)
    ensure
      ENV['WORKAREA_KLARNA_ON_SITE_MESSAGING_CLIENT_ID'] = @_kosm_env
      Rails.application.credentials.klarna = @_kosm_cred
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-klarna-1.1.0 test/lib/workarea/klarna_test.rb
workarea-klarna-1.1.0.beta1 test/lib/workarea/klarna_test.rb