Sha256: 8e05e326da5ffff2e56de0b3496970b4744579262a403f43fac060ff364cbfe5

Contents?: true

Size: 959 Bytes

Versions: 62

Compression:

Stored size: 959 Bytes

Contents

require 'test_helper'

module Workarea
  module Storefront
    class CurrentUserIntegrationTest < Workarea::IntegrationTest
      def test_returns_admin_true_when_impersonating
        admin_user = create_user(password: 'W3bl1nc!', super_admin: true)
        non_admin = create_user

        post storefront.login_path,
          params: { email: admin_user.email, password: 'W3bl1nc!' }

        get storefront.current_user_path(format: 'json')
        results = JSON.parse(response.body)
        assert(results['admin'])

        post admin.impersonations_path, params: { user_id: non_admin.id }

        get storefront.current_user_path(format: 'json')
        results = JSON.parse(response.body)

        assert(results['admin'], 'user is not admin')
        assert_equal(ApplicationController.request_forgery_protection_token.to_s, results['csrf_param'])
        assert(results['csrf_token'].present?, 'csrf token not found')
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-storefront-3.5.27 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.26 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.45 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.25 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.23 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.44 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.22 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.43 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.21 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.42 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.20 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.41 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.19 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.40 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.18 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.39 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.17 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.38 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.16 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.37 test/integration/workarea/storefront/current_user_integration_test.rb