Skip to content

add tests about link check for nested resource routes#636

Open
senid231 wants to merge 1 commit intoJSONAPI-Resources:masterfrom
senid231:nested_links_tests
Open

add tests about link check for nested resource routes#636
senid231 wants to merge 1 commit intoJSONAPI-Resources:masterfrom
senid231:nested_links_tests

Conversation

@senid231
Copy link
Copy Markdown
Contributor

jsonapi_resource generate incorrect links when using nested resources
routes.rb

jsonapi_resources :writers do
  jsonapi_resources :posts
end

4 tests failed:

Minitest::Assertion: --- expected
+++ actual
@@ -1 +1 @@
-{"self"=>"http://www.example.com/nested_api/writers/1/posts/1/relationships/writer", "related"=>"http://www.example.com/nested_api/writers/1"}
+{"self"=>"http://www.example.com/nested_api/posts/1/relationships/writer", "related"=>"http://www.example.com/nested_api/posts/1/writer"}


Minitest::Assertion: --- expected
+++ actual
@@ -1 +1 @@
-{"first"=>"http://www.example.com/nested_api/writers/1/posts?page%5Bnumber%5D=1&page%5Bsize%5D=1", "next"=>"http://www.example.com/nested_api/writers/1/posts?page%5Bnumber%5D=2&page%5Bsize%5D=1", "last"=>"http://www.example.com/nested_api/writers/1/posts?page%5Bnumber%5D=3&page%5Bsize%5D=1"}
+{"first"=>"http://www.example.com/nested_api/posts?page%5Bnumber%5D=1&page%5Bsize%5D=1", "next"=>"http://www.example.com/nested_api/posts?page%5Bnumber%5D=2&page%5Bsize%5D=1", "last"=>"http://www.example.com/nested_api/posts?page%5Bnumber%5D=3&page%5Bsize%5D=1"}


Minitest::Assertion: --- expected
+++ actual
@@ -1 +1 @@
-"application/vnd.api+json"
+#<Mime::Type:0xXXXXXX @synonyms=["application/xhtml+xml"], @symbol=:html, @string="text/html">


Minitest::Assertion: --- expected
+++ actual
@@ -1 +1 @@
-{"self"=>"http://www.example.com/nested_api/writers/1/posts/1"}
+{"self"=>"http://www.example.com/nested_api/posts/1"}

@Fivell
Copy link
Copy Markdown

Fivell commented Feb 26, 2016

+1, we experiencing serious problems , while using nested resources.
cc @lgebhardt

@lgebhardt
Copy link
Copy Markdown
Contributor

Nested resources are not yet a supported feature. It would be good to get this added to the project.

Comment thread test/test_helper.rb

namespace :nested_api do
jsonapi_resources :writers do
jsonapi_resources :posts
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@senid231 , did you try to change
jsonapi_resources :posts
to
jsonapi_related_resources :posts
?

@senid231
Copy link
Copy Markdown
Contributor Author

senid231 commented May 8, 2016

jsonapi_related_resources is not what i need. it just creates creates get endpoint like /writers/1/posts for posts relationship but not for posts resources

@bananartist
Copy link
Copy Markdown

Any updates on when the feature will be available? In my opinion this is a major bug !
Waiting it I am going to search how to overwrite those links or don't send them at all (if somebody did it, I'll take it !)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants