You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: features/publishable/publishable.feature
+16-1Lines changed: 16 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -219,7 +219,8 @@ Feature: Access to unpublished/draft resources should be configurable
219
219
@loginAdmin
220
220
Scenario: As a user with draft access, when I update a published resource with a draft resource available, it should update and return the draft resource.
221
221
Given there is a published resource with a draft set to publish at "2999-12-31T23:59:59+00:00"
222
-
When I send a "PUT" request to the resource "publishable_draft" with body:
222
+
And I add "Content-Type" header equal to "application/merge-patch+json"
223
+
When I send a "PATCH" request to the resource "publishable_published" with body:
223
224
"""
224
225
{
225
226
"reference": "updated"
@@ -229,6 +230,20 @@ Feature: Access to unpublished/draft resources should be configurable
229
230
And the JSON node "publishedAt" should be equal to "2999-12-31T23:59:59+00:00"
230
231
And the JSON node "reference" should be equal to "updated"
231
232
233
+
@loginAdmin
234
+
Scenario: As a user with draft access, when I update a published with no draft, it should update and return a draft resource.
235
+
Given there is a publishable resource set to publish at "1970-12-31T23:59:59+00:00"
236
+
And I add "Content-Type" header equal to "application/merge-patch+json"
237
+
When I send a "PATCH" request to the resource "publishable_published" with body:
238
+
"""
239
+
{
240
+
"reference": "updated_again"
241
+
}
242
+
"""
243
+
Then the response status code should be 200
244
+
And the JSON node "publishedAt" should be null
245
+
And the JSON node "reference" should be equal to "updated_again"
246
+
232
247
@loginAdmin
233
248
Scenario Outline: As a user with draft access, when I update a published resource with a publication date in the past (or now), it should be ignored.
234
249
Given there is a publishable resource set to publish at "1970-12-31T23:59:59+00:00"
// if we sent 2 simultaneous requests then the initial sql query will have got the live version even if there is a draft now, so let's re-check before creating
@@ -244,6 +254,9 @@ public function createDraft(object $object, Publishable $configuration, string $
244
254
// Add draft object to UnitOfWork
245
255
$em->persist($draft);
246
256
257
+
// todo: perhaps we need to flush here so if we get another request before flushed, we do not get a duplicate key sql error trying to create a draft when one already exists
258
+
$em->flush($draft);
259
+
247
260
// Clear the cache of the published resource because it should now also return an associated draft
0 commit comments