Skip to content

Commit 6bf58d3

Browse files
test: accepts meta in data of POST resource request
1 parent c33e9db commit 6bf58d3

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/Meta/RequestMetaTests.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,42 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
412412
ValidateMetaData(store.Document.Meta);
413413
}
414414

415+
[Fact]
416+
public async Task Accepts_meta_in_data_of_post_resource_request()
417+
{
418+
// Arrange
419+
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
420+
421+
SupportTicket existingTicket = _fakers.SupportTicket.GenerateOne();
422+
423+
var requestBody = new
424+
{
425+
data = new
426+
{
427+
type = "supportTickets",
428+
attributes = new
429+
{
430+
description = existingTicket.Description
431+
},
432+
meta = GetExampleMetaData()
433+
}
434+
};
435+
436+
string route = $"/supportTickets/{existingTicket.StringId}";
437+
438+
// Act
439+
(HttpResponseMessage httpResponse, _) = await _testContext.ExecutePostAsync<Document>(route, requestBody);
440+
441+
// Assert
442+
httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created);
443+
444+
store.Document.Should().NotBeNull();
445+
store.Document.Data.Should().NotBeNull();
446+
store.Document.Data.SingleValue.Should().NotBeNull();
447+
448+
ValidateMetaData(store.Document.Data.SingleValue.Meta);
449+
}
450+
415451
private static Object GetExampleMetaData()
416452
{
417453
return new

0 commit comments

Comments
 (0)