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.15 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.36 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.14 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.35 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.13 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.34 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.12 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.33 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.11 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.10 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.32 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.9 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.31 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.8 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.30 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.7 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.29 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.6 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.28 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.5 test/integration/workarea/storefront/current_user_integration_test.rb