Sha256: 32da29980c8b2f601730c58eb02b77e3a40c644893f43367cfd507c93e4d2fcd
Contents?: true
Size: 657 Bytes
Versions: 2
Compression:
Stored size: 657 Bytes
Contents
require 'test_helper' class ProtectedResourcesControllerTest < ActionController::TestCase def authenticate @user = users(:one) @token = Knock::AuthToken.new(payload: { sub: @user.id }).token @request.env['HTTP_AUTHORIZATION'] = "Bearer #{@token}" end test "responds with unauthorized" do get :index assert_response :unauthorized end test "responds with success if authenticated" do authenticate get :index assert_response :success end test "has a current_user after authentication" do authenticate get :index assert_response :success assert @controller.current_user.id == @user.id end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
knock-1.3.0 | test/dummy/test/controllers/protected_resources_controller_test.rb |
knock-1.2.0 | test/dummy/test/controllers/protected_resources_controller_test.rb |