File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
tests/lib/Integration/Eloquent Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ All notable changes to this project will be documented in this file. This projec
1212Resolve model bindings correctly when substituting URL parameters.
1313- Updated type-hinting for ` Responses::errros() ` method and allowed a ` null ` default
1414status code to be passed to ` Helpers::httpErrorStatus() ` method.
15+ - [ #518 ] ( https://github.com/cloudcreativity/laravel-json-api/issues/518 )
16+ Ensure empty ` sort ` and ` include ` query parameters pass validation.
1517
1618## [ 2.0.0-beta.3] - 2020-04-13
1719
Original file line number Diff line number Diff line change @@ -655,6 +655,7 @@ protected function defaultQueryRules(): array
655655 ],
656656 'include ' => [
657657 'bail ' ,
658+ 'nullable ' ,
658659 'string ' ,
659660 $ this ->allowedIncludePaths (),
660661 ],
@@ -665,6 +666,7 @@ protected function defaultQueryRules(): array
665666 ],
666667 'sort ' => [
667668 'bail ' ,
669+ 'nullable ' ,
668670 'string ' ,
669671 $ this ->allowedSortParameters (),
670672 ],
Original file line number Diff line number Diff line change @@ -67,6 +67,15 @@ public function testSortedSearch()
6767 ->assertFetchedManyInOrder ([$ b , $ a ]);
6868 }
6969
70+ public function testEmptySort (): void
71+ {
72+ $ posts = factory (Post::class, 2 )->create ();
73+
74+ $ this ->jsonApi ()
75+ ->get ('api/v1/posts?sort= ' )
76+ ->assertFetchedMany ($ posts );
77+ }
78+
7079 public function testFilteredSearch ()
7180 {
7281 $ a = factory (Post::class)->create ([
@@ -329,6 +338,18 @@ public function testReadWithInclude()
329338 ->assertIsIncluded ('tags ' , $ tag );
330339 }
331340
341+ /**
342+ * @see https://github.com/cloudcreativity/laravel-json-api/issues/518
343+ */
344+ public function testReadWithEmptyInclude (): void
345+ {
346+ $ post = factory (Post::class)->create ();
347+
348+ $ this ->jsonApi ()
349+ ->get ("api/v1/posts/ {$ post ->getRouteKey ()}?include= " )
350+ ->assertFetchedOne ($ this ->serialize ($ post ));
351+ }
352+
332353 /**
333354 * @see https://github.com/cloudcreativity/laravel-json-api/issues/194
334355 */
You can’t perform that action at this time.
0 commit comments