Sha256: 12496d627548f6152a7bb4bc512341f7ab2365a8b0c76ea6450c2dd722cdf7a0

Contents?: true

Size: 501 Bytes

Versions: 4

Compression:

Stored size: 501 Bytes

Contents

require 'test_helper'

class CurrentUsersControllerTest < ActionController::TestCase
  setup do
    @user = users(:one)
    @token = Knock::AuthToken.new(payload: { sub: @user.id }).token
  end

  def authenticate token: @token
    @request.env['HTTP_AUTHORIZATION'] = "Bearer #{token}"
  end

  test "responds with 404 if user is not logged in" do
    get :show
    assert_response :not_found
  end

  test "responds with 200" do
    authenticate
    get :show
    assert_response :success
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
knock-1.5 test/dummy/test/controllers/current_users_controller_test.rb
knock-1.4.2 test/dummy/test/controllers/current_users_controller_test.rb
knock-1.4.1 test/dummy/test/controllers/current_users_controller_test.rb
knock-1.4.0 test/dummy/test/controllers/current_users_controller_test.rb