Skip to content

Commit c33e9db

Browse files
test: accepts top level meta in atomic REMOVE resource request
1 parent eeebcd9 commit c33e9db

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/Meta/RequestMetaTests.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,53 @@ public async Task Accepts_top_level_meta_in_atomic_add_resource_operation()
365365
ValidateMetaData(store.Document.Meta);
366366
}
367367

368+
[Fact]
369+
public async Task Accepts_top_level_meta_in_atomic_remove_resource_operation()
370+
{
371+
// Arrange
372+
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
373+
374+
SupportTicket existingTicket = _fakers.SupportTicket.GenerateOne();
375+
376+
await _testContext.RunOnDatabaseAsync(async dbContext =>
377+
{
378+
dbContext.SupportTickets.Add(existingTicket);
379+
await dbContext.SaveChangesAsync();
380+
});
381+
382+
var requestBody = new
383+
{
384+
atomic__operations = new[]
385+
{
386+
new
387+
{
388+
op = "remove",
389+
@ref = new
390+
{
391+
type = "supportTickets",
392+
id = existingTicket.StringId
393+
}
394+
}
395+
},
396+
meta = GetExampleMetaData()
397+
};
398+
399+
string route = $"/operations";
400+
401+
// Act
402+
(HttpResponseMessage httpResponse, string responseDocument) = await _testContext.ExecutePostAtomicAsync<string>(route, requestBody);
403+
404+
// Assert
405+
httpResponse.ShouldHaveStatusCode(HttpStatusCode.NoContent);
406+
407+
responseDocument.Should().BeEmpty();
408+
409+
store.Document.Should().NotBeNull();
410+
store.Document.Meta.Should().NotBeNull();
411+
412+
ValidateMetaData(store.Document.Meta);
413+
}
414+
368415
private static Object GetExampleMetaData()
369416
{
370417
return new

0 commit comments

Comments
 (0)