Получение runtime error: Could not find a valid mapping for nil
при попытке запустить тесты на контроллере JSON с аутентификацией Devise JWT. Есть идеи, что я пропустил?
Контроллер
class Api::V1::TestController < ApplicationController
before_action :authenticate_user!
def index
render json: {
message: 'Sucessfully ran test API v1 endpoint.'
},
status: :ok
end
end
Test
require 'rails_helper'
require 'devise/jwt/test_helpers'
RSpec.describe Api::V1::TestController, type: :controller do
context "Test Controller" do
it 'should return Forbidden with message from Test API' do
headers = { 'Accept' => 'application/json', 'Content-Type' => 'application/json' }
auth_headers = Devise::JWT::TestHelpers.auth_headers(headers, nil)
get :index, headers: auth_headers
assert_response :unauthorized
end
end
end
Error
Api::V1::TestController Test Controller should return OK with message from Test API
Failure/Error: auth_headers = Devise::JWT::TestHelpers.auth_headers(headers, user)
RuntimeError:
Could not find a valid mapping for nil