Sha256: b21f84b3b58f2af9ab46ed68bc20fb3d11ee0d8488ecc15b2fbd4b4f5c5cb77b

Contents?: true

Size: 1.26 KB

Versions: 21

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require 'test_helper'

class Custom::TokenValidationsControllerTest < ActionDispatch::IntegrationTest
  describe Custom::TokenValidationsController do
    include CustomControllersRoutes

    before do
      @resource = create(:user, :confirmed)

      @auth_headers = @resource.create_new_auth_token

      @token     = @auth_headers['access-token']
      @client_id = @auth_headers['client']
      @expiry    = @auth_headers['expiry']

      # ensure that request is not treated as batch request
      age_token(@resource, @client_id)
    end

    test 'yield resource to block on validate_token success' do
      get '/nice_user_auth/validate_token',
          params: {},
          headers: @auth_headers
      assert @controller.validate_token_block_called?,
             'validate_token failed to yield resource to provided block'
    end

    test 'yield resource to block on validate_token success with custom json' do
      get '/nice_user_auth/validate_token',
          params: {},
          headers: @auth_headers

      @data = JSON.parse(response.body)

      assert @controller.validate_token_block_called?,
             'validate_token failed to yield resource to provided block'
      assert_equal @data['custom'], 'foo'
    end
  end
end

Version data entries

21 entries across 21 versions & 6 rubygems

Version Path
devise_token_auth-1.2.5 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth-1.2.4 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth-1.2.2 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth-1.2.1 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth-1.2.0 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth-1.1.5 test/controllers/custom/custom_token_validations_controller_test.rb
sidecar_token_auth-1.0.1 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth-1.1.4 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth_multitenancy-1.1.3.2 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth_multitenancy-1.1.3.1 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth_multitenancy-1.1.3.alpha1 test/controllers/custom/custom_token_validations_controller_test.rb
devise-tokens-1.0.4 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth-1.1.3 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth-1.1.2 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth-1.1.1 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth-1.1.0 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth_fork_dfabarbosa-1.0.0 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth_skycocker_fork-1.0.0 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth-1.0.0 test/controllers/custom/custom_token_validations_controller_test.rb
devise_token_auth-1.0.0.rc2 test/controllers/custom/custom_token_validations_controller_test.rb