This issue is a (choose one):
Checklist before submitting:
Description
In trying to update to Rails 7.1 I'm running into random instances of this error when running my test suite.
Error:
Jsonapi::V1::TeamProjectsControllerTest#test_should_not_create_for_a_forbidden_team:
NameError: uninitialized constant JSONAPI::ResourceController
app/controllers/jsonapi/v1/base_controller.rb:3:in `<main>'
app/controllers/jsonapi/v1/team_projects_controller.rb:1:in `<main>'
test/controllers/jsonapi/v1/team_projects_controller_test.rb:126:in `block in <class:TeamProjectsControllerTest>'
Sometimes there will be 2 of them, other times 20 or 30.
Via some trial and error I discovered that if I alter my BaseController to look like this:
class Jsonapi::V1::BaseController < ActionController::Base
include JSONAPI::ActsAsResourceController
# ...
end
Instead of this:
class Jsonapi::V1::BaseController < JSONAPI::ResourceController
# ...
end
then the random errors go away.
I also noticed that these errors were only happening locally, and not in CI, and so I tried setting config.eager_load = true in config/environments/test.rb which also made the errors go away.
I poked around this gem a little bit and I think that this block of code isn't exactly working as expected in Rail 7.1.
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/lib/jsonapi-resources.rb#L12-L18
Ruby: 3.3.6
Rails: 7.1.5.1
This issue is a (choose one):
Checklist before submitting:
Description
In trying to update to Rails 7.1 I'm running into random instances of this error when running my test suite.
Sometimes there will be 2 of them, other times 20 or 30.
Via some trial and error I discovered that if I alter my
BaseControllerto look like this:Instead of this:
then the random errors go away.
I also noticed that these errors were only happening locally, and not in CI, and so I tried setting
config.eager_load = trueinconfig/environments/test.rbwhich also made the errors go away.I poked around this gem a little bit and I think that this block of code isn't exactly working as expected in Rail 7.1.
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/lib/jsonapi-resources.rb#L12-L18
Ruby: 3.3.6
Rails: 7.1.5.1