Skip to content

Commit fdac076

Browse files
fix cleanup-code task
1 parent 35e6533 commit fdac076

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

test/JsonApiDotNetCoreTests/IntegrationTests/Meta/RequestMetaTests.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
182182
store.Document.Data.SingleValue.Meta.Should().BeEquivalentToJson(resourceMeta);
183183

184184
store.Document.Data.SingleValue.Relationships.Should().NotBeNull();
185+
185186
store.Document.Data.SingleValue.Relationships.Should().ContainKey("tickets").WhoseValue.With(value =>
186187
{
187188
value.Should().NotBeNull();
@@ -567,6 +568,60 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
567568
store.Document.Meta.Should().BeEquivalentToJson(documentMeta);
568569
}
569570

571+
[Fact]
572+
public async Task Accepts_meta_in_delete_relationship_request_with_identifier_meta()
573+
{
574+
// Arrange
575+
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
576+
577+
Dictionary<string, object?> documentMeta = _fakers.DocumentMeta.GenerateOne();
578+
Dictionary<string, object?> identifierMeta = _fakers.RelationshipIdentifierMeta.GenerateOne();
579+
580+
SupportTicket existingTicket = _fakers.SupportTicket.GenerateOne();
581+
ProductFamily existingFamily = _fakers.ProductFamily.GenerateOne();
582+
583+
await _testContext.RunOnDatabaseAsync(async dbContext =>
584+
{
585+
dbContext.ProductFamilies.Add(existingFamily);
586+
existingTicket.ProductFamily = existingFamily;
587+
dbContext.SupportTickets.Add(existingTicket);
588+
await dbContext.SaveChangesAsync();
589+
});
590+
591+
var requestBody = new
592+
{
593+
data = new[]
594+
{
595+
new
596+
{
597+
type = "supportTickets",
598+
id = existingTicket.StringId,
599+
meta = identifierMeta
600+
}
601+
},
602+
meta = documentMeta
603+
};
604+
605+
string route = $"/productFamilies/{existingFamily.StringId}/relationships/tickets";
606+
607+
// Act
608+
(HttpResponseMessage httpResponse, _) = await _testContext.ExecuteDeleteAsync<Document>(route, requestBody);
609+
610+
// Assert
611+
httpResponse.ShouldHaveStatusCode(HttpStatusCode.NoContent);
612+
613+
store.Document.Should().NotBeNull();
614+
615+
store.Document.Data.SingleValue.Should().BeNull();
616+
617+
store.Document.Meta.Should().BeEquivalentToJson(documentMeta);
618+
619+
store.Document.Data.Should().NotBeNull();
620+
store.Document.Data.ManyValue.Should().HaveCount(1);
621+
622+
store.Document.Data.ManyValue[0].Meta.Should().BeEquivalentToJson(identifierMeta);
623+
}
624+
570625
private sealed class CapturingDocumentAdapter : IDocumentAdapter
571626
{
572627
private readonly IDocumentAdapter _innerAdapter;

0 commit comments

Comments
 (0)