File tree 2 files changed +17
-3
lines changed
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ export default class Model extends StaticModel {
167
167
return this
168
168
}
169
169
170
- /**
170
+ /**
171
171
* Result
172
172
*/
173
173
@@ -189,8 +189,8 @@ export default class Model extends StaticModel {
189
189
if ( identifier === undefined ) {
190
190
throw new Error ( 'You must specify the param on find() method.' )
191
191
}
192
-
193
- let url = `${ this . baseURL ( ) } / ${ this . resource ( ) } /${ identifier } ${ this . _builder . query ( ) } `
192
+ let base = this . _fromResource || ` ${ this . baseURL ( ) } / ${ this . resource ( ) } `
193
+ let url = `${ base } /${ identifier } ${ this . _builder . query ( ) } `
194
194
195
195
return this . request ( {
196
196
url,
Original file line number Diff line number Diff line change @@ -325,6 +325,20 @@ describe('Model methods', () => {
325
325
posts = await user . posts ( ) . get ( )
326
326
} )
327
327
328
+ test ( 'a request from hasMany() with a find() hits right resource' , async ( ) => {
329
+ let user
330
+ let post
331
+
332
+ axiosMock . onAny ( ) . reply ( ( config ) => {
333
+ expect ( config . method ) . toEqual ( 'get' )
334
+ expect ( config . url ) . toEqual ( 'http://localhost/users/1/posts/1' )
335
+ return [ 200 , { } ]
336
+ } )
337
+
338
+ user = new User ( { id : 1 } )
339
+ post = await user . posts ( ) . find ( 1 )
340
+ } )
341
+
328
342
test ( 'a request hasMany() method returns a array of Models' , async ( ) => {
329
343
330
344
axiosMock . onGet ( 'http://localhost/users/1/posts' ) . reply ( 200 , postsResponse )
You can’t perform that action at this time.
0 commit comments