File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
src/Examples/JsonApiDotNetCoreExample/Models
test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ public class Person : Identifiable, IHasMeta
2020
2121 [ HasMany ( "todo-collections" ) ]
2222 public virtual List < TodoItemCollection > TodoItemCollections { get ; set ; }
23+
24+ [ HasOne ( "unincludeable-item" , Link . All , false ) ]
25+ public virtual TodoItem UnIncludeableItem { get ; set ; }
2326
2427 public Dictionary < string , object > GetMeta ( IJsonApiContext context )
2528 {
Original file line number Diff line number Diff line change @@ -335,5 +335,29 @@ public async Task Request_ToIncludeDeeplyNestedRelationships_Returns_400()
335335 // assert
336336 Assert . Equal ( HttpStatusCode . BadRequest , response . StatusCode ) ;
337337 }
338+
339+ [ Fact ]
340+ public async Task Request_ToIncludeRelationshipMarkedCanIncludeFalse_Returns_400 ( )
341+ {
342+ // arrange
343+ var person = _context . People . First ( ) ;
344+
345+ var builder = new WebHostBuilder ( )
346+ . UseStartup < Startup > ( ) ;
347+
348+ var httpMethod = new HttpMethod ( "GET" ) ;
349+
350+ var route = $ "/api/v1/people/{ person . Id } ?include=unincludeable-item";
351+
352+ var server = new TestServer ( builder ) ;
353+ var client = server . CreateClient ( ) ;
354+ var request = new HttpRequestMessage ( httpMethod , route ) ;
355+
356+ // act
357+ var response = await client . SendAsync ( request ) ;
358+
359+ // assert
360+ Assert . Equal ( HttpStatusCode . BadRequest , response . StatusCode ) ;
361+ }
338362 }
339363}
You can’t perform that action at this time.
0 commit comments