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.4.27 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.4 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.26 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.3 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.25 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.2 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.24 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.1 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.23 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.22 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.0 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.21 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.5.0.beta.1 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.20 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.19 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.18 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.17 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.16 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.15 test/integration/workarea/storefront/current_user_integration_test.rb
workarea-storefront-3.4.14 test/integration/workarea/storefront/current_user_integration_test.rb