mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
closes #101 - data model updates
Further changes to the data model to ensure created_by, author_id and updated_by are all set to user 1 Updated settings such that the default type is always 'general', and changed the types in the fixtures to be slightly more useful Added additional assertions to tests to cover more assumptions about data
This commit is contained in:
parent
316985feab
commit
d15f1f8961
5 changed files with 39 additions and 15 deletions
|
@ -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"
|
||||
}
|
||||
],
|
||||
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
hasTimestamps: true,
|
||||
defaults: function () {
|
||||
return {
|
||||
uuid: uuid.v4()
|
||||
uuid: uuid.v4(),
|
||||
type: 'general'
|
||||
};
|
||||
}
|
||||
}, {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue