Sha256: fb988c54ecb68f3d073a60073fa2c3e430837868c274958cd9450f6f482cff3e
Contents?: true
Size: 691 Bytes
Versions: 41
Compression:
Stored size: 691 Bytes
Contents
require 'test_helper' # Secure Ping Controller Test class SecuredPingControllerTest < ActionController::TestCase def with_a_valid_token @user = { id: 1 } @token = Knock::AuthToken.new(payload: { sub: @user[:id] }).token @request.env['HTTP_AUTHORIZATION'] = "Bearer #{@token}" end test 'responds with unauthorized' do get :ping assert_response :unauthorized end test 'responds with success when passing a valid token' do with_a_valid_token get :ping assert_response :success end test '@current_user is set when passing a valid token' do with_a_valid_token get :ping assert_equal @user[:id], @controller.current_user[:id] end end
Version data entries
41 entries across 41 versions & 1 rubygems