@@ -113,6 +113,65 @@ public async Task Accepts_top_level_meta_in_post_resource_request()
113113 ValidateMetaData ( store . Document . Meta ) ;
114114 }
115115
116+ [ Fact ]
117+ public async Task Accepts_top_level_meta_in_patch_relationship_request ( )
118+ {
119+ // Arrange
120+ var store = _testContext . Factory . Services . GetRequiredService < RequestDocumentStore > ( ) ;
121+
122+ SupportTicket existingTicket = _fakers . SupportTicket . GenerateOne ( ) ;
123+
124+ ProductFamily existingProductFamily = _fakers . ProductFamily . GenerateOne ( ) ;
125+
126+ await _testContext . RunOnDatabaseAsync ( async dbContext =>
127+ {
128+ dbContext . ProductFamilies . Add ( existingProductFamily ) ;
129+ dbContext . SupportTickets . Add ( existingTicket ) ;
130+ await dbContext . SaveChangesAsync ( ) ;
131+ } ) ;
132+
133+ var requestBody = new
134+ {
135+ data = new
136+ {
137+ type = "supportTickets" ,
138+ id = existingTicket . StringId ,
139+ attributes = new
140+ {
141+ description = existingTicket . Description
142+ } ,
143+ relationships = new
144+ {
145+ productFamily = new
146+ {
147+ data = new
148+ {
149+ type = "productFamilies" ,
150+ id = existingProductFamily . StringId
151+ }
152+ }
153+ }
154+ } ,
155+ meta = GetExampleMetaData ( )
156+ } ;
157+
158+ string route = $ "/supportTickets/{ existingTicket . StringId } ";
159+
160+ // Act
161+ ( HttpResponseMessage httpResponse , _ ) = await _testContext . ExecutePatchAsync < Document > ( route , requestBody ) ;
162+
163+ // Assert
164+ httpResponse . ShouldHaveStatusCode ( HttpStatusCode . NoContent ) ;
165+
166+ store . Document . Should ( ) . NotBeNull ( ) ;
167+
168+ store . Document . Data . SingleValue . Should ( ) . NotBeNull ( ) ;
169+ store . Document . Data . SingleValue . Relationships . Should ( ) . NotBeNull ( ) ;
170+ store . Document . Data . SingleValue . Relationships . Should ( ) . HaveCount ( 1 ) ;
171+
172+ ValidateMetaData ( store . Document . Meta ) ;
173+ }
174+
116175 private static Object GetExampleMetaData ( )
117176 {
118177 return new
0 commit comments