diff --git a/core/server/models/post.js b/core/server/models/post.js index 6cbfdbe3fd..8099d229b3 100644 --- a/core/server/models/post.js +++ b/core/server/models/post.js @@ -782,6 +782,12 @@ Post = ghostBookshelf.Model.extend({ edit: function edit(data, unfilteredOptions) { let options = this.filterOptions(unfilteredOptions, 'edit', {extraAllowedProperties: ['id']}); + // @TODO DELETE THIS (and the failing regression tests) when v0.1 is ded + if (Object.prototype.hasOwnProperty.call(data, 'page')) { + data.type = data.page ? 'page' : 'post'; + delete data.page; + } + const editPost = () => { options.forUpdate = true; diff --git a/core/test/regression/api/v2/admin/schedules_spec.js b/core/test/regression/api/v2/admin/schedules_spec.js index 6a0abbffe2..c1385cd7ef 100644 --- a/core/test/regression/api/v2/admin/schedules_spec.js +++ b/core/test/regression/api/v2/admin/schedules_spec.js @@ -80,7 +80,7 @@ describe('Schedules API', function () { published_at: moment().add(30, 'seconds').toDate(), status: 'scheduled', slug: 'fifth', - page: true + type: 'page' })); return Promise.mapSeries(resources, function (post) { diff --git a/core/test/regression/api/v2/content/utils.js b/core/test/regression/api/v2/content/utils.js index 6da3f963f8..2a7f12ace9 100644 --- a/core/test/regression/api/v2/content/utils.js +++ b/core/test/regression/api/v2/content/utils.js @@ -25,6 +25,7 @@ const expectedProperties = { .without('status') // @TODO: https://github.com/TryGhost/Ghost/issues/10335 // .without('page') + .without('type') // v2 returns a calculated excerpt field .concat('excerpt') , diff --git a/core/test/regression/models/model_posts_spec.js b/core/test/regression/models/model_posts_spec.js index d6b4d2a7dc..2be4568cf1 100644 --- a/core/test/regression/models/model_posts_spec.js +++ b/core/test/regression/models/model_posts_spec.js @@ -532,7 +532,7 @@ describe('Post Model', function () { }).then(function (edited) { should.exist(edited); edited.attributes.status.should.equal('draft'); - edited.attributes.page.should.equal(true); + edited.attributes.type.should.equal('page'); Object.keys(eventsTriggered).length.should.eql(2); should.exist(eventsTriggered['post.deleted']); @@ -542,7 +542,7 @@ describe('Post Model', function () { }).then(function (edited) { should.exist(edited); edited.attributes.status.should.equal('draft'); - edited.attributes.page.should.equal(false); + edited.attributes.type.should.equal('post'); Object.keys(eventsTriggered).length.should.eql(4); should.exist(eventsTriggered['post.deleted']); @@ -569,7 +569,7 @@ describe('Post Model', function () { }).then(function (edited) { should.exist(edited); edited.attributes.status.should.equal('scheduled'); - edited.attributes.page.should.equal(true); + edited.attributes.type.should.equal('page'); Object.keys(eventsTriggered).length.should.eql(3); should.exist(eventsTriggered['post.deleted']); @@ -580,7 +580,7 @@ describe('Post Model', function () { }).then(function (edited) { should.exist(edited); edited.attributes.status.should.equal('scheduled'); - edited.attributes.page.should.equal(false); + edited.attributes.type.should.equal('post'); Object.keys(eventsTriggered).length.should.eql(7); should.exist(eventsTriggered['page.unscheduled']); @@ -606,7 +606,7 @@ describe('Post Model', function () { }).then(function (edited) { should.exist(edited); edited.attributes.status.should.equal('published'); - edited.attributes.page.should.equal(true); + edited.attributes.type.should.equal('page'); Object.keys(eventsTriggered).length.should.eql(4); should.exist(eventsTriggered['post.unpublished']); @@ -618,7 +618,7 @@ describe('Post Model', function () { }).then(function (edited) { should.exist(edited); edited.attributes.status.should.equal('published'); - edited.attributes.page.should.equal(false); + edited.attributes.type.should.equal('post'); Object.keys(eventsTriggered).length.should.eql(8); should.exist(eventsTriggered['page.unpublished']); @@ -644,7 +644,7 @@ describe('Post Model', function () { }).then(function (edited) { should.exist(edited); edited.attributes.status.should.equal('published'); - edited.attributes.page.should.equal(true); + edited.attributes.type.should.equal('page'); Object.keys(eventsTriggered).length.should.eql(5); should.exist(eventsTriggered['post.deleted']); @@ -657,7 +657,7 @@ describe('Post Model', function () { }).then(function (edited) { should.exist(edited); edited.attributes.status.should.equal('draft'); - edited.attributes.page.should.equal(false); + edited.attributes.type.should.equal('post'); Object.keys(eventsTriggered).length.should.eql(8); should.exist(eventsTriggered['page.unpublished']); @@ -1175,7 +1175,7 @@ describe('Post Model', function () { page = results.toJSON(); page.id.should.equal(firstItemData.id); page.status.should.equal('published'); - page.page.should.be.true(); + page.type.should.equal('page'); // Destroy the page return results.destroy(firstItemData); diff --git a/core/test/regression/site/site_spec.js b/core/test/regression/site/site_spec.js index cb7a767777..bfd93db41c 100644 --- a/core/test/regression/site/site_spec.js +++ b/core/test/regression/site/site_spec.js @@ -1915,7 +1915,7 @@ describe('Integration - Web - Site', function () { response.statusCode.should.eql(200); response.template.should.eql('tag'); - postSpy.args[0][0].options.filter.should.eql('(tags:\'bacon\'+tags.visibility:public)+page:false'); + postSpy.args[0][0].options.filter.should.eql('(tags:\'bacon\'+tags.visibility:public)+type:post'); postSpy.args[0][0].options.page.should.eql(1); postSpy.args[0][0].options.limit.should.eql(2); });