Skip to content

Commit 1498a0b

Browse files
test: accepts top level meta in atomic UPDATE resource request
1 parent b68dd8f commit 1498a0b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/Meta/RequestMetaTests.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using JsonApiDotNetCore.Serialization.Objects;
55
using JsonApiDotNetCore.Serialization.Request.Adapters;
66
using JsonApiDotNetCore.Serialization.Response;
7+
using Microsoft.EntityFrameworkCore;
78
using Microsoft.Extensions.DependencyInjection;
89
using TestBuildingBlocks;
910
using Xunit;
@@ -274,6 +275,54 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
274275
ValidateMetaData(store.Document.Meta);
275276
}
276277

278+
[Fact]
279+
public async Task Accepts_top_level_meta_in_atomic_update_resource_operation()
280+
{
281+
// Arrange
282+
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
283+
284+
SupportTicket existingTicket = _fakers.SupportTicket.GenerateOne();
285+
286+
await _testContext.RunOnDatabaseAsync(async dbContext =>
287+
{
288+
dbContext.SupportTickets.Add(existingTicket);
289+
await dbContext.SaveChangesAsync();
290+
});
291+
292+
var requestBody = new
293+
{
294+
atomic__operations = new[]
295+
{
296+
new
297+
{
298+
op = "update",
299+
data = new
300+
{
301+
type = "supportTickets",
302+
id = existingTicket.StringId,
303+
attributes = new
304+
{
305+
description = existingTicket.Description
306+
}
307+
}
308+
}
309+
},
310+
meta = GetExampleMetaData()
311+
};
312+
313+
string route = $"/operations";
314+
315+
// Act
316+
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecutePostAtomicAsync<Document>(route, requestBody);
317+
318+
// Assert
319+
httpResponse.ShouldHaveStatusCode(HttpStatusCode.NoContent);
320+
321+
store.Document.Should().NotBeNull();
322+
323+
ValidateMetaData(store.Document.Meta);
324+
}
325+
277326
private static Object GetExampleMetaData()
278327
{
279328
return new

0 commit comments

Comments
 (0)