diff --git a/packages/strapi-plugin-content-manager/services/ContentManager.js b/packages/strapi-plugin-content-manager/services/ContentManager.js index 2382b15df9..5446898c3f 100644 --- a/packages/strapi-plugin-content-manager/services/ContentManager.js +++ b/packages/strapi-plugin-content-manager/services/ContentManager.js @@ -58,7 +58,8 @@ module.exports = { }, edit(params, { data, files }, { model } = {}) { - return strapi.entityService.update({ params, data, files }, { model }); + const publishData = _.omit(data, PUBLISHED_AT_ATTRIBUTE); + return strapi.entityService.update({ params, data: publishData, files }, { model }); }, delete(model, query) { diff --git a/packages/strapi/__tests__/api/basic-dp.test.e2e.js b/packages/strapi/__tests__/api/basic-dp.test.e2e.js index d50f69d357..c4d8a9257e 100644 --- a/packages/strapi/__tests__/api/basic-dp.test.e2e.js +++ b/packages/strapi/__tests__/api/basic-dp.test.e2e.js @@ -82,7 +82,7 @@ describe('Core API - Basic + draftAndPublish', () => { data.products.push(res.body); }); - test('Create a product + cannot overwrite published_at', async () => { + test('Create a product + can overwrite published_at', async () => { const product = { name: 'Product 2', description: 'Product description', @@ -97,7 +97,7 @@ describe('Core API - Basic + draftAndPublish', () => { expect(res.statusCode).toBe(200); expect(res.body).toMatchObject(_.omit(product, 'published_at')); expect(res.body.published_at).toBeISODate(); - expect(res.body.published_at).not.toBe(product.published_at); + expect(res.body.published_at).toBe(product.published_at); data.products.push(res.body); }); @@ -141,7 +141,7 @@ describe('Core API - Basic + draftAndPublish', () => { data.products[0] = res.body; }); - test('Update product + cannot overwrite published_at', async () => { + test('Update product + can overwrite published_at', async () => { const product = { name: 'Product 1 updated', description: 'Updated Product description', @@ -155,9 +155,8 @@ describe('Core API - Basic + draftAndPublish', () => { expect(res.statusCode).toBe(200); expect(res.body).toMatchObject(_.pick(data.products[0], ['name', 'description'])); - expect(res.body.published_at).toBe(data.products[0].published_at); expect(res.body.published_at).toBeISODate(); - expect(res.body.published_at).not.toBe(product.published_at); + expect(res.body.published_at).toBe(product.published_at); data.products[0] = res.body; });