diff --git a/core/shared/data/fixtures/001.js b/core/shared/data/fixtures/001.js index 7070c00c3b..235969582f 100644 --- a/core/shared/data/fixtures/001.js +++ b/core/shared/data/fixtures/001.js @@ -18,9 +18,9 @@ module.exports = { "status": "published", "featured": true, "author_id": 1, - "created_at": 1352475600601, + "created_at": '2012-11-09T15:40:46.776Z', "created_by": 1, - "published_at": 1352475600601, + "published_at": '2012-11-09T15:40:46.776Z', "published_by": 1 }, { @@ -37,9 +37,9 @@ module.exports = { "status": "published", "featured": true, "author_id": 1, - "created_at": 1340582400102, + "created_at": '2012-06-25T01:00:23.776Z', "created_by": 1, - "published_at": 1340582400102, + "published_at": '2012-06-25T01:00:23.776Z', "published_by": 1 } ], @@ -51,7 +51,7 @@ module.exports = { "value": "http://localhost:3333", "created_by": 1, "updated_by": 1, - "type": "general" + "type": "blog" }, { "uuid": uuid.v4(), @@ -59,7 +59,7 @@ module.exports = { "value": "John O'Nolan", "created_by": 1, "updated_by": 1, - "type": "general" + "type": "blog" }, { "uuid": uuid.v4(), @@ -67,7 +67,7 @@ module.exports = { "value": "Interactive designer, public speaker, startup advisor and writer. Living in Austria, attempting world domination via keyboard.", "created_by": 1, "updated_by": 1, - "type": "general" + "type": "blog" }, { "uuid": uuid.v4(), @@ -99,7 +99,7 @@ module.exports = { "value": "001", "created_by": 1, "updated_by": 1, - "type": "general" + "type": "core" } ], diff --git a/core/shared/models/post.js b/core/shared/models/post.js index 11538822ab..04b3f5427b 100644 --- a/core/shared/models/post.js +++ b/core/shared/models/post.js @@ -23,6 +23,7 @@ return { uuid: uuid.v4(), status: 'draft' + // TODO: language: ghost.config().defaultLang); }; }, @@ -43,15 +44,22 @@ this.set('published_by', 1); } + this.set('updated_by', 1); // refactoring of ghost required in order to make these details available here - // this.set('language', this.get('language') || ghost.config().defaultLang); - // this.set('status', this.get('status') || ghost.statuses().draft); }, creating: function () { if (!this.get('slug')) { this.generateSlug(); } + + if (!this.get('created_by')) { + this.set('created_by', 1); + } + + if (!this.get('author_id')) { + this.set('author_id', 1); + } }, generateSlug: function () { diff --git a/core/shared/models/settings.js b/core/shared/models/settings.js index 5ce76fb248..06dce01fc9 100644 --- a/core/shared/models/settings.js +++ b/core/shared/models/settings.js @@ -15,7 +15,8 @@ hasTimestamps: true, defaults: function () { return { - uuid: uuid.v4() + uuid: uuid.v4(), + type: 'general' }; } }, { diff --git a/core/test/ghost/api_posts_spec.js b/core/test/ghost/api_posts_spec.js index 6f68e26eaf..04eddc901e 100644 --- a/core/test/ghost/api_posts_spec.js +++ b/core/test/ghost/api_posts_spec.js @@ -64,10 +64,11 @@ }); it('can add, defaulting as a draft', function (done) { - var newPost = { - title: 'Test Title 1', - content: 'Test Content 1' - }; + var createdPostUpdatedDate, + newPost = { + title: 'Test Title 1', + content: 'Test Content 1' + }; PostModel.add(newPost).then(function (createdPost) { return new PostModel({id: createdPost.id}).fetch(); @@ -78,12 +79,25 @@ createdPost.get('title').should.equal(newPost.title, "title is correct"); createdPost.get('content').should.equal(newPost.content, "content is correct"); createdPost.get('slug').should.equal(newPost.title.toLowerCase().replace(/ /g, '-'), 'slug is correct'); + //createdPost.get('created_at').should.be.instanceOf(Date); - why is this not true? + createdPost.get('created_by').should.equal(1); + createdPost.get('author_id').should.equal(1); + createdPost.get('created_by').should.equal(createdPost.get('author_id')); + //createdPost.get('updated_at').should.be.instanceOf(Date); - why is this not true? + createdPost.get('updated_by').should.equal(1); should.equal(createdPost.get('published_at'), null); + should.equal(createdPost.get('published_by'), null); + + createdPostUpdatedDate = createdPost.get('updated_at'); // Set the status to published to check that `published_at` is set. return createdPost.save({status: 'published'}); }).then(function (publishedPost) { publishedPost.get('published_at').should.be.instanceOf(Date); + publishedPost.get('published_by').should.equal(1); + publishedPost.get('updated_at').should.be.instanceOf(Date); + publishedPost.get('updated_by').should.equal(1); + publishedPost.get('updated_at').should.not.equal(createdPostUpdatedDate); done(); }).then(null, done); diff --git a/core/test/ghost/api_settings_spec.js b/core/test/ghost/api_settings_spec.js index 637afb57f2..8d3b5f9d6b 100644 --- a/core/test/ghost/api_settings_spec.js +++ b/core/test/ghost/api_settings_spec.js @@ -140,6 +140,7 @@ createdSetting.has('uuid').should.equal(true); createdSetting.attributes.key.should.equal(newSetting.key, "key is correct"); createdSetting.attributes.value.should.equal(newSetting.value, "value is correct"); + createdSetting.attributes.type.should.equal("general"); done(); }).then(null, done);