Skip to content

Commit b68dd8f

Browse files
test: accepts top level meta in DELETE relationship request
1 parent d34319e commit b68dd8f

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/Meta/RequestMetaTests.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,52 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
228228
ValidateMetaData(store.Document.Meta);
229229
}
230230

231+
[Fact]
232+
public async Task Accepts_top_level_meta_in_delete_relationship_request()
233+
{
234+
// Arrange
235+
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
236+
237+
SupportTicket existingTicket = _fakers.SupportTicket.GenerateOne();
238+
239+
ProductFamily existingProductFamily = _fakers.ProductFamily.GenerateOne();
240+
241+
await _testContext.RunOnDatabaseAsync(async dbContext =>
242+
{
243+
existingTicket.ProductFamily = existingProductFamily;
244+
dbContext.SupportTickets.Add(existingTicket);
245+
await dbContext.SaveChangesAsync();
246+
});
247+
248+
var requestBody = new
249+
{
250+
data = (object?)null,
251+
meta = GetExampleMetaData()
252+
};
253+
254+
string route = $"/supportTickets/{existingTicket.StringId}/relationships/productFamily";
255+
256+
// Act
257+
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecutePatchAsync<Document>(route, requestBody);
258+
259+
// Assert
260+
httpResponse.ShouldHaveStatusCode(HttpStatusCode.NoContent);
261+
262+
store.Document.Should().NotBeNull();
263+
store.Document.Data.SingleValue.Should().BeNull();
264+
265+
await _testContext.RunOnDatabaseAsync(async dbContext =>
266+
{
267+
var supportTicketInDatabase = await dbContext.SupportTickets
268+
.Include(supportTicket => supportTicket.ProductFamily)
269+
.FirstAsync(supportTicket => supportTicket.Id == existingTicket.Id);
270+
271+
supportTicketInDatabase.ProductFamily.Should().BeNull();
272+
});
273+
274+
ValidateMetaData(store.Document.Meta);
275+
}
276+
231277
private static Object GetExampleMetaData()
232278
{
233279
return new

0 commit comments

Comments
 (0)