Teach jsonapi:resource
generator to respect namespaced models and controllers
#141
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes the issue with namespaced models.
rails generate jsonapi:resource Blog::Post
Before
app/serializables/blog/serializable_post.rb
file withSerializableBlog::Post
class inside (💣 breaks autoloading).app/controllers/blog/posts_controller.rb
,but
config/routes.rb
includes:rails generate factory_bot:model Blog::Post
is called:blog_post
,but API request specs try to
create(:post)
(💣 Factory not registered! )spec/api/v1/posts/blog/{create,destroy,index,show,update}_spec.rb
(←posts/blog
? what is that?)jsonapi_{get,delete,post,put} '/api/v1/posts'
(💣 which nothing can handle)After:
app/serializables/blog/serializable_post.rb
file withBlog::SerializablePost
class inside.app/controllers/blog/posts_controller.rb
,and
config/routes.rb
includesrails generate factory_bot:model Blog::Post
is called:blog_post
,and API requests specs try to
create(:blog_post)
spec/api/v1/blog/posts/{create,destroy,index,show,update}_spec.rb
(←blog/posts
, according to generated controller)jsonapi_{get,delete,post,put} '/api/v1/blog/posts'
(which is handled by generatedBlog::PostsController