You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require'bundler/inline'gemfile(true)dosource'https://rubygems.org'git_source(:github){ |repo| "https://github.com/#{repo}.git"}gem'json_api_client','1.8.0'endclassResource < JsonApiClient::Resourceself.site='http://example.com/api'endclassAuthor < ResourceendclassStore < ResourceendclassBook < Resourcebelongs_to:author,shallow_path: truebelongs_to:store,shallow_path: trueendrequire'minitest/autorun'classPathTest < MiniTest::Testdeftest_pathassert_equal'books',Book.path({})# This breaks because the result is `/books` instead of `books`enddeftest_getBook.all# Sends requests to http://example.com/books instead of http://example.com/api/booksendend
a.set_prefix_path(attrs, route_formatter) can return nil if using shallow_path. If there are 2 or more belongs_to association in the resource, paths.join("/") would return extra slashes ([nil, nil].join('/') => '/').
Steps to reproduce:
What's wrong:
This part of code:
json_api_client/lib/json_api_client/resource.rb
Line 324 in db890ad
a.set_prefix_path(attrs, route_formatter)
can returnnil
if usingshallow_path
. If there are 2 or morebelongs_to
association in the resource,paths.join("/")
would return extra slashes ([nil, nil].join('/') => '/'
).Possible fix:
Remove
nil
s:Also, I'm not sure what
_prefix_path
is meant to do so maybe we need to fix that method too.The text was updated successfully, but these errors were encountered: