Merge pull request #2692 from cobbspur/newerror

updated error handling on all mocha tests
This commit is contained in:
Hannah Wolfe 2014-05-05 22:58:28 +01:00
commit d4b1693a2c
35 changed files with 298 additions and 299 deletions

View File

@ -67,7 +67,7 @@ describe('Admin Routing', function () {
return testUtils.initData();
}).then(function () {
done();
}, done);
}).catch(done);
}).otherwise(function (e) {
console.log('Ghost Error: ', e);
console.log(e.stack);
@ -126,8 +126,8 @@ describe('Admin Routing', function () {
forkedGhost = child;
request = require('supertest');
request = request(configTestHttps.url.replace(/\/$/, ''));
}, done)
.then(done);
}).then(done)
.catch(done);
});
after(function (done) {
@ -162,8 +162,8 @@ describe('Admin Routing', function () {
forkedGhost = child;
request = require('supertest');
request = request(configTestHttps.url.replace(/\/$/, ''));
}, done)
.then(done);
}).then(done)
.catch(done);
});
after(function (done) {
@ -342,7 +342,7 @@ describe('Authenticated Admin Routing', function () {
});
});
}, done);
}).catch(done);
}).otherwise(function (e) {
console.log('Ghost Error: ', e);
console.log(e.stack);

View File

@ -31,7 +31,7 @@ describe('Unauthorized', function () {
return testUtils.initData();
}).then(function () {
done();
}, done);
}).catch(done);
});
});

View File

@ -70,8 +70,8 @@ describe('Post API', function () {
});
});
}, done);
}).otherwise(function (e) {
}).catch(done);
}).catch(function (e) {
console.log('Ghost Error: ', e);
console.log(e.stack);
});

View File

@ -69,8 +69,8 @@ describe('Settings API', function () {
});
});
}, done);
}).otherwise(function (e) {
}).catch(done);
}).catch(function (e) {
console.log('Ghost Error: ', e);
console.log(e.stack);
});

View File

@ -69,8 +69,8 @@ describe('Tag API', function () {
});
});
}, done);
}).otherwise(function (e) {
}).catch(done);
}).catch(function (e) {
console.log('Ghost Error: ', e);
console.log(e.stack);
});

View File

@ -67,8 +67,8 @@ describe('User API', function () {
});
});
}, done);
}).otherwise(function (e) {
}).catch(done);
}).catch(function (e) {
console.log('Ghost Error: ', e);
console.log(e.stack);
});

View File

@ -52,8 +52,8 @@ describe('Frontend Routing', function () {
return testUtils.initData();
}).then(function () {
done();
}, done);
}).otherwise(function (e) {
}).catch(done);
}).catch(function (e) {
console.log('Ghost Error: ', e);
console.log(e.stack);
});
@ -157,8 +157,7 @@ describe('Frontend Routing', function () {
forkedGhost = child;
request = require('supertest');
request = request(configTestHttps.url.replace(/\/$/, ''));
}, done)
.then(done);
}).then(done).catch(done);
});
after(function (done) {
@ -232,7 +231,7 @@ describe('Frontend Routing', function () {
return testUtils.insertMorePosts(11);
}).then(function () {
done();
}).then(null, done);
}).catch(done);
});
it('should redirect without slash', function (done) {
@ -419,7 +418,7 @@ describe('Frontend Routing', function () {
.expect('Cache-Control', cacheRules.year)
.expect(200)
.end(doEnd(done));
})
});
// at the moment there is no image fixture to test
// it('should retrieve image assets', function (done) {
@ -441,11 +440,11 @@ describe('Frontend Routing', function () {
return testUtils.insertPosts();
}).then(function () {
return testUtils.insertMorePosts(22);
}).then(function() {
}).then(function () {
return testUtils.insertMorePostsTags(22);
}).then(function () {
done();
}).then(null, done);
}).catch(done);
});

View File

@ -14,7 +14,7 @@ describe('DB API', function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
@ -26,13 +26,13 @@ describe('DB API', function () {
return testUtils.insertAuthorUser();
}).then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
it('delete all content', function (done) {
@ -53,7 +53,7 @@ describe('DB API', function () {
results.posts.length.should.equal(0);
done();
});
}).otherwise(function (error) {
}).catch(function (error) {
done(new Error(JSON.stringify(error)));
});
});
@ -73,7 +73,7 @@ describe('DB API', function () {
return dbAPI.deleteAllContent();
}).then(function (){
done(new Error("Delete all content is not denied without authentication."));
}, function (error) {
}).catch(function (error) {
error.type.should.eql('NoPermission');
done();
});
@ -94,7 +94,7 @@ describe('DB API', function () {
return dbAPI.exportContent();
}).then(function (){
done(new Error("Export content is not denied without authentication."));
}, function (error) {
}).catch(function (error) {
error.type.should.eql('NoPermission');
done();
});
@ -115,7 +115,7 @@ describe('DB API', function () {
return dbAPI.importContent();
}).then(function (result){
done(new Error("Import content is not denied without authentication."));
}, function (error) {
}).catch(function (error) {
error.type.should.eql('NoPermission');
done();
});

View File

@ -11,7 +11,7 @@ describe('Notifications API', function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
@ -21,13 +21,13 @@ describe('Notifications API', function () {
})
.then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
it('can browse', function (done) {
@ -43,7 +43,7 @@ describe('Notifications API', function () {
results.length.should.be.above(0);
testUtils.API.checkResponse(results[0], 'notification');
done();
});
}).catch(done);
});
});
});

View File

@ -11,7 +11,7 @@ describe('Post API', function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
@ -21,13 +21,13 @@ describe('Post API', function () {
})
.then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
it('can browse', function (done) {
@ -38,7 +38,7 @@ describe('Post API', function () {
results.posts.length.should.be.above(0);
testUtils.API.checkResponse(results.posts[0], 'post');
done();
}).then(null, done);
}).catch(done);
});
it('can read', function (done) {
@ -63,6 +63,6 @@ describe('Post API', function () {
testUtils.API.checkResponse(post.tags[0], 'tag');
done();
}).then(null, done);
}).catch(done);
});
});

View File

@ -11,7 +11,7 @@ describe('Settings API', function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
@ -24,13 +24,13 @@ describe('Settings API', function () {
})
.then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
it('can browse', function (done) {

View File

@ -11,7 +11,7 @@ describe('Tags API', function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
@ -21,13 +21,13 @@ describe('Tags API', function () {
})
.then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
it('can browse', function (done) {
@ -37,6 +37,6 @@ describe('Tags API', function () {
results.tags.length.should.be.above(0);
testUtils.API.checkResponse(results.tags[0], 'tag');
done();
}).then(null, done);
}).catch(done);
});
});

View File

@ -14,7 +14,7 @@ describe('App Fields Model', function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
@ -24,19 +24,19 @@ describe('App Fields Model', function () {
})
.then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
after(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
it('can browse', function (done) {
@ -47,7 +47,7 @@ describe('App Fields Model', function () {
results.length.should.be.above(0);
done();
}).then(null, done);
}).catch(done);
});
it('can read', function (done) {
@ -55,7 +55,7 @@ describe('App Fields Model', function () {
should.exist(foundAppField);
done();
}).then(null, done);
}).catch(done);
});
it('can edit', function (done) {
@ -71,6 +71,6 @@ describe('App Fields Model', function () {
updatedAppField.get("value").should.equal("350");
done();
}).then(null, done);
}).catch(done);
});
});

View File

@ -14,7 +14,7 @@ describe('App Setting Model', function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
@ -24,19 +24,19 @@ describe('App Setting Model', function () {
})
.then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
after(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
it('can browse', function (done) {
@ -47,7 +47,7 @@ describe('App Setting Model', function () {
results.length.should.be.above(0);
done();
}).then(null, done);
}).catch(done);
});
it('can read', function (done) {
@ -55,7 +55,7 @@ describe('App Setting Model', function () {
should.exist(foundAppSetting);
done();
}).then(null, done);
}).catch(done);
});
it('can edit', function (done) {
@ -71,6 +71,6 @@ describe('App Setting Model', function () {
updatedAppSetting.get("value").should.equal("350");
done();
}).then(null, done);
}).catch(done);
});
});

View File

@ -14,7 +14,7 @@ describe('App Model', function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
@ -24,19 +24,19 @@ describe('App Model', function () {
})
.then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
after(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
it('can browse', function (done) {
@ -47,7 +47,7 @@ describe('App Model', function () {
results.length.should.be.above(0);
done();
}).then(null, done);
}).catch(done);
});
it('can read', function (done) {
@ -55,7 +55,7 @@ describe('App Model', function () {
should.exist(foundApp);
done();
}).then(null, done);
}).catch(done);
});
it('can edit', function (done) {
@ -71,7 +71,7 @@ describe('App Model', function () {
updatedApp.get("name").should.equal("New App");
done();
}).then(null, done);
}).catch(done);
});
it("can add", function (done) {
@ -83,7 +83,7 @@ describe('App Model', function () {
createdApp.attributes.name.should.equal(newApp.name);
done();
}).then(null, done);
}).catch(done);
});
it("can delete", function (done) {
@ -101,6 +101,6 @@ describe('App Model', function () {
hasRemovedId.should.equal(false);
done();
}).then(null, done);
}).catch(done);
});
});

View File

@ -15,19 +15,19 @@ describe("Permission Model", function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
testUtils.initData().then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
it("can browse permissions", function (done) {
@ -45,7 +45,7 @@ describe("Permission Model", function () {
should.exist(foundPermission);
done();
}).then(null, done);
}).catch(done);
});
it("can edit permissions", function (done) {
@ -61,7 +61,7 @@ describe("Permission Model", function () {
updatedPermission.get("name").should.equal("updated");
done();
}).then(null, done);
}).catch(done);
});
it("can add permissions", function (done) {
@ -77,7 +77,7 @@ describe("Permission Model", function () {
createdPerm.attributes.name.should.equal(newPerm.name);
done();
}).then(null, done);
}).catch(done);
});
it("can delete permissions", function (done) {
@ -95,6 +95,6 @@ describe("Permission Model", function () {
hasRemovedId.should.equal(false);
done();
}).then(null, done);
}).catch(done);
});
});

View File

@ -16,7 +16,7 @@ describe('Post Model', function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
@ -26,13 +26,13 @@ describe('Post Model', function () {
})
.then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
it('can browse', function (done) {
@ -45,7 +45,7 @@ describe('Post Model', function () {
//results.models[0].attributes.published_at.should.be.above(results.models[1].attributes.published_at);
done();
}).then(null, done);
}).catch(done);
});
it('can read', function (done) {
@ -62,7 +62,7 @@ describe('Post Model', function () {
found.attributes.title.should.equal(firstPost.attributes.title);
done();
}).then(null, done);
}).catch(done);
});
it('can findAll, returning author and field data', function (done) {
@ -80,7 +80,7 @@ describe('Post Model', function () {
firstPost.fields[0].key.should.equal(DataGenerator.Content.app_fields[0].key);
done();
}, done);
}).catch(done);
});
it('can findOne, returning author and field data', function (done) {
@ -97,7 +97,7 @@ describe('Post Model', function () {
firstPost.fields[0].key.should.equal(DataGenerator.Content.app_fields[0].key);
done();
}, done);
}).catch(done);
});
it('can edit', function (done) {
@ -114,7 +114,7 @@ describe('Post Model', function () {
edited.attributes.title.should.equal('new title');
done();
}).then(null, done);
}).catch(done);
});
it('can add, defaults are all correct', function (done) {
@ -163,7 +163,7 @@ describe('Post Model', function () {
publishedPost.get('updated_at').should.not.equal(createdPostUpdatedDate);
done();
}).then(null, done);
}).catch(done);
});
@ -182,7 +182,7 @@ describe('Post Model', function () {
done();
}).otherwise(done);
}).catch(done);
});
it('can trim title', function (done) {
@ -204,7 +204,7 @@ describe('Post Model', function () {
updatedPost.get('title').should.equal(untrimmedUpdateTitle.trim());
done();
}).otherwise(done);
}).catch(done);
});
it('can generate a non conflicting slug', function (done) {
@ -240,7 +240,7 @@ describe('Post Model', function () {
});
done();
}).otherwise(done);
}).catch(done);
});
it('can generate slugs without duplicate hyphens', function (done) {
@ -254,7 +254,7 @@ describe('Post Model', function () {
createdPost.get('slug').should.equal('apprehensive-titles-have-too-many-spaces-and-m-dashes-and-also-n-dashes');
done();
}).then(null, done);
}).catch(done);
});
it('can generate a safe slug when a reserved keyword is used', function(done) {
@ -278,7 +278,7 @@ describe('Post Model', function () {
PostModel.add(newPost, {user: 1}).then(function (createdPost) {
createdPost.get('slug').should.equal('bhute-dhddkii-bhrvnnaaraa-aahet');
done();
});
}).catch(done);
});
it('detects duplicate slugs before saving', function (done) {
@ -326,7 +326,7 @@ describe('Post Model', function () {
foundPost.get('slug').should.not.equal(firstPost.slug);
done();
}).otherwise(done);
}).catch(done);
});
it('can delete', function (done) {
@ -349,7 +349,7 @@ describe('Post Model', function () {
hasDeletedId.should.equal(false);
done();
}).then(null, done);
}).catch(done);
});
it('can fetch a paginated set, with various options', function (done) {
@ -427,7 +427,7 @@ describe('Post Model', function () {
paginationResult.posts.length.should.equal(11);
done();
}).then(null, done);
}).catch(done);
});
// disabling sanitization until we can implement a better version

View File

@ -15,19 +15,19 @@ describe("Role Model", function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
testUtils.initData().then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
it("can browse roles", function (done) {
@ -37,7 +37,7 @@ describe("Role Model", function () {
foundRoles.models.length.should.be.above(0);
done();
}).then(null, done);
}).catch(done);
});
it("can read roles", function (done) {
@ -45,7 +45,7 @@ describe("Role Model", function () {
should.exist(foundRole);
done();
}).then(null, done);
}).catch(done);
});
it("can edit roles", function (done) {
@ -61,7 +61,7 @@ describe("Role Model", function () {
updatedRole.get("name").should.equal("updated");
done();
}).then(null, done);
}).catch(done);
});
it("can add roles", function (done) {
@ -77,7 +77,7 @@ describe("Role Model", function () {
createdRole.attributes.description.should.equal(newRole.description);
done();
}).then(null, done);
}).catch(done);
});
it("can delete roles", function (done) {
@ -95,6 +95,6 @@ describe("Role Model", function () {
hasRemovedId.should.equal(false);
done();
}).then(null, done);
}).catch(done);
});
});

View File

@ -14,25 +14,25 @@ describe('Settings Model', function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
testUtils.initData().then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
after(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
describe('API', function () {
@ -45,7 +45,7 @@ describe('Settings Model', function () {
results.length.should.be.above(0);
done();
}).then(null, done);
}).catch(done);
});
it('can read', function (done) {
@ -69,7 +69,7 @@ describe('Settings Model', function () {
done();
}).then(null, done);
}).catch(done);
});
it('can edit single', function (done) {
@ -95,7 +95,7 @@ describe('Settings Model', function () {
done();
}).then(null, done);
}).catch(done);
});
it('can edit multiple', function (done) {
@ -132,7 +132,7 @@ describe('Settings Model', function () {
done();
}).then(null, done);
}).catch(done);
});
it('can add', function (done) {
@ -150,7 +150,7 @@ describe('Settings Model', function () {
createdSetting.attributes.type.should.equal("core");
done();
}).then(null, done);
}).catch(done);
});
it('can delete', function (done) {
@ -186,7 +186,7 @@ describe('Settings Model', function () {
done();
}).then(null, done);
}).catch(done);
});
});
@ -213,7 +213,7 @@ describe('Settings Model', function () {
// but it's easier to fix the test if that ever changes than to mock out that behaviour
descriptionSetting.get('value').should.equal('Just a blogging platform.');
done();
}).then(null, done);
}).catch(done);
});
it('doesn\'t overwrite any existing settings', function (done) {
@ -224,7 +224,7 @@ describe('Settings Model', function () {
}).then(function (descriptionSetting) {
descriptionSetting.get('value').should.equal('Adam\'s Blog');
done();
}).then(null, done);
}).catch(done);
});
});

View File

@ -15,20 +15,20 @@ describe('Tag Model', function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
testUtils.initData()
.then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
describe('a Post', function () {
@ -53,7 +53,7 @@ describe('Tag Model', function () {
}).then(function (postWithTag) {
postWithTag.related('tags').length.should.equal(1);
done();
}).then(null, done);
}).catch(done);
});
@ -85,7 +85,7 @@ describe('Tag Model', function () {
}).then(function (postWithoutTag) {
postWithoutTag.related('tags').length.should.equal(0);
done();
}).then(null, done);
}).catch(done);
});
describe('setting tags from an array on update', function () {
@ -135,8 +135,7 @@ describe('Tag Model', function () {
tagsFromDB.length.should.eql(seededTagNames.length + 1);
done();
}).then(null, done);
}).catch(done);
});
it('detaches tags that have been removed', function (done) {
@ -156,7 +155,7 @@ describe('Tag Model', function () {
tagNames.sort().should.eql(['tag1', 'tag3']);
done();
}).then(null, done);
}).catch(done);
});
it('attaches tags that are new to the post, but already exist in the database', function (done) {
@ -186,7 +185,7 @@ describe('Tag Model', function () {
Math.max.apply(Math, tagIds).should.eql(4);
done();
}).then(null, done);
}).catch(done);
});
it('creates and attaches a tag that is new to the Tags table', function (done) {
@ -206,7 +205,7 @@ describe('Tag Model', function () {
tagNames.sort().should.eql(['tag1', 'tag2', 'tag3']);
done();
}).then(null, done);
}).catch(done);
});
it('creates and attaches multiple tags that are new to the Tags table', function (done) {
@ -227,7 +226,7 @@ describe('Tag Model', function () {
tagNames.sort().should.eql(['tag1', 'tag2', 'tag3']);
done();
}).then(null, done);
}).catch(done);
});
it('attaches one tag that exists in the Tags database and one tag that is new to the Tags database', function (done) {
@ -262,7 +261,7 @@ describe('Tag Model', function () {
Math.max.apply(Math, tagIds).should.eql(4);
done();
}).then(null, done);
}).catch(done);
});
it('attaches one tag that exists in the Tags database and two tags that are new to the Tags database', function (done) {
@ -298,7 +297,7 @@ describe('Tag Model', function () {
Math.max.apply(Math, tagIds).should.eql(5);
done();
}).then(null, done);
}).catch(done);
});
it('can add a tag to a post on creation', function (done) {
@ -309,7 +308,7 @@ describe('Tag Model', function () {
}).then(function (postWithTag) {
postWithTag.related('tags').length.should.equal(1);
done();
}).then(null, done);
}).catch(done);
});
});

View File

@ -17,7 +17,7 @@ describe('User Model', function run() {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
@ -30,7 +30,7 @@ describe('User Model', function run() {
beforeEach(function (done) {
testUtils.initData().then(function () {
done();
}, done);
}).catch(done);
});
it('can add first', function (done) {
@ -46,7 +46,7 @@ describe('User Model', function run() {
createdUser.attributes.email.should.eql(userData.email, "email address correct");
gravatarStub.restore();
done();
}).then(null, done);
}).catch(done);
});
it('does NOT lowercase email', function (done) {
@ -61,7 +61,7 @@ describe('User Model', function run() {
createdUser.attributes.email.should.eql(userData.email, "email address correct");
gravatarStub.restore();
done();
}).then(null, done);
}).catch(done);
});
it('can find gravatar', function (done) {
@ -77,7 +77,7 @@ describe('User Model', function run() {
createdUser.attributes.image.should.eql('http://www.gravatar.com/avatar/2fab21a4c4ed88e76add10650c73bae1?d=404', 'Gravatar found');
gravatarStub.restore();
done();
}).then(null, done);
}).catch(done);
});
it('can handle no gravatar', function (done) {
@ -92,7 +92,7 @@ describe('User Model', function run() {
should.not.exist(createdUser.image);
gravatarStub.restore();
done();
}).then(null, done);
}).catch(done);
});
it('can find by email and is case insensitive', function (done) {
@ -125,7 +125,7 @@ describe('User Model', function run() {
});
}).then(function () {
done();
}).then(null, done);
}).catch(done);
});
});
@ -138,7 +138,7 @@ describe('User Model', function run() {
})
.then(function () {
done();
}, done);
}).catch(done);
});
it('sets last login time on successful login', function (done) {
@ -147,7 +147,7 @@ describe('User Model', function run() {
UserModel.check({email: userData.email, pw:userData.password}).then(function (activeUser) {
should.exist(activeUser.get('last_login'));
done();
}).then(null, done);
}).catch(done);
});
it('can\'t add second', function (done) {
@ -156,7 +156,7 @@ describe('User Model', function run() {
return UserModel.add(userData, {user: 1}).then(done, function (failure) {
failure.message.should.eql('A user is already registered. Only one user for now!');
done();
}).then(null, done);
}).catch(done);
});
it('can browse', function (done) {
@ -168,7 +168,7 @@ describe('User Model', function run() {
done();
}).then(null, done);
}).catch(done);
});
it('can read', function (done) {
@ -192,7 +192,7 @@ describe('User Model', function run() {
done();
}).then(null, done);
}).catch(done);
});
@ -217,7 +217,7 @@ describe('User Model', function run() {
done();
}).then(null, done);
}).catch(done);
});
it('can delete', function (done) {
@ -253,7 +253,7 @@ describe('User Model', function run() {
hasDeletedId.should.equal(false);
done();
}).then(null, done);
}).catch(done);
});
it('can generate reset token', function (done) {
@ -271,7 +271,7 @@ describe('User Model', function run() {
token.length.should.be.above(0);
done();
}).then(null, done);
}).catch(done);
});
it('can validate a reset token', function (done) {
@ -291,7 +291,7 @@ describe('User Model', function run() {
done();
}).then(null, done);
}).catch(done);
});
it('can reset a password with a valid token', function (done) {
@ -321,7 +321,7 @@ describe('User Model', function run() {
resetPassword.should.not.equal(origPassword);
done();
}).then(null, done);
}).catch(done);
});
it('doesn\'t allow expired timestamp tokens', function (done) {
@ -341,7 +341,7 @@ describe('User Model', function run() {
return UserModel.validateToken(token, dbHash);
}).then(function () {
throw new Error("Allowed expired token");
}, function (err) {
}).catch(function (err) {
should.exist(err);
@ -376,7 +376,7 @@ describe('User Model', function run() {
}).then(function () {
throw new Error("allowed invalid token");
}, function (err) {
}).catch(function (err) {
should.exist(err);

View File

@ -148,7 +148,7 @@ describe('Apps', function () {
appProxy.filters.deregister('testFilter', 5, filterStub);
done();
})
.otherwise(done);
.catch(done);
});
it('does not allow filter registration without permission', function () {
@ -201,7 +201,7 @@ describe('Apps', function () {
filterStub.called.should.equal(false);
done();
})
.otherwise(done);
.catch(done);
});
it('does not allow filter deregistration without permission', function () {
@ -358,7 +358,7 @@ describe('Apps', function () {
deps.install().then(function () {
deps.spawnCommand.calledWith('npm').should.equal(true);
done();
}).otherwise(done);
}).catch(done);
_.delay(function () {
fakeEmitter.emit('exit');
@ -373,7 +373,7 @@ describe('Apps', function () {
deps.install().then(function () {
deps.spawnCommand.called.should.equal(false);
done();
}).otherwise(done);
}).catch(done);
_.defer(function () {
fakeEmitter.emit('exit');
@ -441,7 +441,7 @@ describe('Apps', function () {
readPerms.should.equal(AppPermissions.DefaultPermissions);
done();
}).otherwise(done);
}).catch(done);
});
it('uses default permissions if no ghost object in package.json', function (done) {
var perms = new AppPermissions("test"),
@ -458,7 +458,7 @@ describe('Apps', function () {
readPerms.should.equal(AppPermissions.DefaultPermissions);
done();
}).otherwise(done);
}).catch(done);
});
it('rejects when reading malformed package.json', function (done) {
var perms = new AppPermissions("test");
@ -470,7 +470,8 @@ describe('Apps', function () {
perms.read().then(function (readPerms) {
done(new Error('should not resolve'));
}).otherwise(function () {
}).catch(function (err) {
err.message.should.equal('package.json file is malformed');
done();
});
});
@ -500,7 +501,7 @@ describe('Apps', function () {
_.keys(readPerms).length.should.equal(3);
done();
}).otherwise(done);
}).catch(done);
});
});
});

View File

@ -48,7 +48,7 @@ describe('Bootstrap', function () {
config.server.port.should.equal(defaultConfig.server.port);
done();
}).then(null, done);
}).catch(done);
});
it('uses the passed in config file location', function (done) {
@ -60,7 +60,7 @@ describe('Bootstrap', function () {
config.server.port.should.equal(defaultConfig.server.port);
done();
}).then(null, done);
}).catch(done);
});
it('creates the config file if one does not exist', function (done) {
@ -81,7 +81,7 @@ describe('Bootstrap', function () {
existsStub.calledOnce.should.be.true;
resolvedPromise.calledTwice.should.be.true;
done();
}).then(null, done);
}).catch(done);
});
it('accepts valid urls', function (done) {
@ -116,73 +116,73 @@ describe('Bootstrap', function () {
localConfig.url.should.equal('//testurl.com');
done();
}).then(null, done);
}).catch(done);
});
it('rejects invalid urls', function (done) {
// replace the config file with invalid data
overrideConfig({url: 'notvalid'});
bootstrap().otherwise(function (error) {
bootstrap().catch(function (error) {
error.should.include(rejectMessage);
// Next test
overrideConfig({url: 'something.com'});
return bootstrap();
}).otherwise(function (error) {
}).catch(function (error) {
error.should.include(rejectMessage);
done();
}).then(function () {
should.fail('no error was thrown when it should have been');
done();
}).then(done, null);
});
});
it('does not permit subdirectories named ghost', function (done) {
// replace the config file with invalid data
overrideConfig({url: 'http://testurl.com/ghost/'});
bootstrap().otherwise(function (error) {
bootstrap().catch(function (error) {
error.should.include(rejectMessage);
// Next test
overrideConfig({url: 'http://testurl.com/ghost/blog/'});
return bootstrap();
}).otherwise(function (error) {
}).catch(function (error) {
error.should.include(rejectMessage);
// Next test
overrideConfig({url: 'http://testurl.com/blog/ghost'});
return bootstrap();
}).otherwise(function (error) {
}).catch(function (error) {
error.should.include(rejectMessage);
done();
}).then(function () {
should.fail('no error was thrown when it should have been');
done();
}).then(done, null);
});
});
it('requires a database config', function (done) {
// replace the config file with invalid data
overrideConfig({database: null});
bootstrap().otherwise(function (error) {
bootstrap().catch(function (error) {
error.should.include(rejectMessage);
// Next test
overrideConfig({database: {}});
return bootstrap();
}).otherwise(function (error) {
}).catch(function (error) {
error.should.include(rejectMessage);
done();
}).then(function () {
should.fail('no error was thrown when it should have been');
done();
}).then(done, null);
});
});
@ -196,31 +196,31 @@ describe('Bootstrap', function () {
// Next test
overrideConfig({server: null});
return bootstrap();
}).otherwise(function (error) {
}).catch(function (error) {
error.should.include(rejectMessage);
// Next test
overrideConfig({server: {host: null}});
return bootstrap();
}).otherwise(function (error) {
}).catch(function (error) {
error.should.include(rejectMessage);
// Next test
overrideConfig({server: {port: null}});
return bootstrap();
}).otherwise(function (error) {
}).catch(function (error) {
error.should.include(rejectMessage);
// Next test
overrideConfig({server: {host: null, port: null}});
return bootstrap();
}).otherwise(function (error) {
}).catch(function (error) {
error.should.include(rejectMessage);
done();
}).then(function () {
should.fail('no error was thrown when it should have been');
done();
}).then(done, null);
});
});
});

View File

@ -35,13 +35,13 @@ describe('Config', function () {
theme.update(settings, 'http://my-ghost-blog.com')
.then(done)
.then(null, done);
.catch(done);
});
afterEach(function (done) {
theme.update(settings, defaultConfig.url)
.then(done)
.then(null, done);
.catch(done);
sandbox.restore();
});
@ -295,7 +295,7 @@ describe('Config', function () {
url.should.equal('http://my-ghost-blog.com/blog' + postLink);
done();
}).then(null, done);
}).catch(done);
});
@ -336,7 +336,7 @@ describe('Config', function () {
url.should.equal('http://my-ghost-blog.com/blog' + postLink);
done();
}).then(null, done);
}).catch(done);
});
it('should output correct url for page with date permalink', function (done) {
@ -372,7 +372,7 @@ describe('Config', function () {
url.should.equal('http://my-ghost-blog.com/blog' + postLink);
done();
}).then(null, done);
}).catch(done);
});
});
});

View File

@ -366,6 +366,6 @@ describe('Error handling', function () {
next = null;
errors.updateActiveTheme('theme-with-error');
errors.renderErrorPage(code, error, req, res, next);
})
});
});
});

View File

@ -20,21 +20,21 @@ describe("Exporter", function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
sandbox = sinon.sandbox.create();
testUtils.initData().then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
sandbox.restore();
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
it("exports data", function (done) {
@ -63,6 +63,6 @@ describe("Exporter", function () {
migrationStub.restore();
done();
}).then(null, done);
}).catch(done);
});
});

View File

@ -125,7 +125,7 @@ describe("Filters", function () {
newArgs.filter3.should.equal(true);
done();
});
}).catch(done);
});
it("executes filters with a context", function (done) {
@ -147,7 +147,7 @@ describe("Filters", function () {
newArgs.context1.should.equal(true);
newArgs.context2.should.equal(true);
done();
});
}).catch(done);
});
});

View File

@ -124,7 +124,7 @@ describe('Frontend Controller', function () {
res.redirect.calledWith('/page/3/').should.be.true;
res.render.called.should.be.false;
done();
});
}).catch(done);
});
it('Redirects to last page if page number too big with subdirectory', function (done) {
@ -141,7 +141,7 @@ describe('Frontend Controller', function () {
res.redirect.calledWith('/blog/page/3/').should.be.true;
res.render.called.should.be.false;
done();
});
}).catch(done);
});
});
@ -189,12 +189,12 @@ describe('Frontend Controller', function () {
meta: {
pagination: {
page: 1,
pages: 1,
pages: 1
},
filters: {
tags: [mockTags[0]]
}
},
}
});
});
@ -350,7 +350,7 @@ describe('Frontend Controller', function () {
res.redirect.calledWith('/tag/pumpkin/page/3/').should.be.true;
res.render.called.should.be.false;
done();
});
}).catch(done);
});
it('Redirects to last page if page number too big with subdirectory', function (done) {
@ -367,7 +367,7 @@ describe('Frontend Controller', function () {
res.redirect.calledWith('/blog/tag/pumpkin/page/3/').should.be.true;
res.render.called.should.be.false;
done();
});
}).catch(done);
});
});
@ -996,7 +996,7 @@ describe('Frontend Controller', function () {
res.redirect.calledWith('/rss/3/').should.be.true;
res.render.called.should.be.false;
done();
});
}).catch(done);
});
it('Redirects to last page if page number too big with subdirectory', function (done) {
@ -1009,7 +1009,7 @@ describe('Frontend Controller', function () {
res.redirect.calledWith('/blog/rss/3/').should.be.true;
res.render.called.should.be.false;
done();
});
}).catch(done);
});
});

View File

@ -31,7 +31,7 @@ describe("Import", function () {
// clear database... we need to initialise it manually for each test
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function () {
@ -50,7 +50,7 @@ describe("Import", function () {
importStub.restore();
done();
}).then(null, done);
}).catch(done);
});
it("resolves 001", function (done) {
@ -65,7 +65,7 @@ describe("Import", function () {
importStub.restore();
done();
}).then(null, done);
}).catch(done);
});
it("resolves 002", function (done) {
@ -80,7 +80,7 @@ describe("Import", function () {
importStub.restore();
done();
}).then(null, done);
}).catch(done);
});
it("resolves 003", function (done) {
@ -95,7 +95,7 @@ describe("Import", function () {
importStub.restore();
done();
}).then(null, done);
}).catch(done);
});
describe("000", function () {
@ -107,7 +107,7 @@ describe("Import", function () {
return testUtils.insertDefaultUser();
}).then(function () {
done();
}).then(null, done);
}).catch(done);
});
@ -154,7 +154,7 @@ describe("Import", function () {
migrationStub.restore();
done();
}).then(null, done);
}).catch(done);
});
});
@ -167,7 +167,7 @@ describe("Import", function () {
return testUtils.insertDefaultUser();
}).then(function () {
done();
}).then(null, done);
}).catch(done);
});
it("safely imports data from 001", function (done) {
@ -240,7 +240,7 @@ describe("Import", function () {
assert.equal(new Date(posts[1].published_at).getTime(), timestamp);
done();
}).then(null, done);
}).catch(done);
});
it("doesn't import invalid post data from 001", function (done) {
@ -291,7 +291,7 @@ describe("Import", function () {
done();
});
}).then(null, done);
}).catch(done);
});
it("doesn't import invalid settings data from 001", function (done) {
@ -339,7 +339,7 @@ describe("Import", function () {
done();
});
}).then(null, done);
}).catch(done);
});
});
@ -352,7 +352,7 @@ describe("Import", function () {
return testUtils.insertDefaultUser();
}).then(function () {
done();
}).then(null, done);
}).catch(done);
});
it("safely imports data from 002", function (done) {
@ -425,7 +425,7 @@ describe("Import", function () {
assert.equal(new Date(posts[1].published_at).getTime(), timestamp);
done();
}).otherwise(function (error) {
}).catch(function (error) {
done(new Error(error));
});
});
@ -478,7 +478,7 @@ describe("Import", function () {
done();
});
}).then(null, done);
}).catch(done);
});
it("doesn't import invalid settings data from 002", function (done) {
@ -526,7 +526,7 @@ describe("Import", function () {
done();
});
}).then(null, done);
}).catch(done);
});
});
@ -539,7 +539,7 @@ describe("Import", function () {
return testUtils.insertDefaultUser();
}).then(function () {
done();
}).then(null, done);
}).catch(done);
});
it("safely imports data from 003", function (done) {
@ -569,7 +569,7 @@ describe("Import", function () {
// app_settings.length.should.equal(exportData.data.app_settings.length, 'imported app settings');
done();
}).then(null, done);
}).catch(done);
});
});
});

View File

@ -83,7 +83,7 @@ describe("Mail", function () {
mailer.transport.transportType.should.eql('SMTP');
mailer.transport.sendMail.should.be.a.function;
done();
}).then(null, done);
}).catch(done);
});
it('should setup sendmail transport on initialization', function (done) {
@ -93,7 +93,7 @@ describe("Mail", function () {
mailer.transport.transportType.should.eql('SENDMAIL');
mailer.transport.sendMail.should.be.a.function;
done();
}).then(null, done);
}).catch(done);
});
it('should fallback to sendmail if no config set', function (done) {
@ -103,7 +103,7 @@ describe("Mail", function () {
mailer.transport.transportType.should.eql('SENDMAIL');
mailer.transport.options.path.should.eql(fakeSendmail);
done();
}).then(null, done);
}).catch(done);
});
it('should fallback to sendmail if config is empty', function (done) {
@ -113,7 +113,7 @@ describe("Mail", function () {
mailer.transport.transportType.should.eql('SENDMAIL');
mailer.transport.options.path.should.eql(fakeSendmail);
done();
}).then(null, done);
}).catch(done);
});
it('should disable transport if config is empty & sendmail not found', function (done) {
@ -123,7 +123,7 @@ describe("Mail", function () {
mailer.init().then(function () {
should.not.exist(mailer.transport);
done();
}).then(null, done);
}).catch(done);
});
it('should disable transport if config is empty & platform is win32', function (done) {
@ -136,7 +136,7 @@ describe("Mail", function () {
mailer.init().then(function () {
should.not.exist(mailer.transport);
done();
}).then(null, done);
}).catch(done);
});
it('should fail to send messages when no transport is set', function (done) {
@ -146,7 +146,7 @@ describe("Mail", function () {
mailer.send().then(function () {
should.fail();
done();
}, function (err) {
}).catch(function (err) {
err.should.be.an.instanceOf(Error);
done();
});
@ -165,7 +165,7 @@ describe("Mail", function () {
d.reason.should.be.an.instanceOf(Error);
});
done();
});
}).catch(done);
});
it('should use from address as configured in config.js', function (done) {

View File

@ -23,8 +23,8 @@ describe('Middleware', function () {
};
api.notifications.destroyAll().then(function () {
return done();
});
done();
}).catch(done);
});
it('should redirect to signin path', function (done) {
@ -33,8 +33,8 @@ describe('Middleware', function () {
middleware.auth(req, res, null).then(function () {
assert(res.redirect.calledWithMatch('/ghost/signin/'));
return done();
});
done();
}).catch(done);
});
@ -44,8 +44,8 @@ describe('Middleware', function () {
req.path = '/ghost/' + path;
middleware.auth(req, res, null).then(function () {
assert(res.redirect.calledWithMatch('/ghost/signin/?r=' + encodeURIComponent(path)));
return done();
});
done();
}).catch(done);
});
it('should only add one message to the notification array', function (done) {
@ -57,15 +57,15 @@ describe('Middleware', function () {
return api.notifications.browse().then(function (notifications) {
assert.equal(notifications.length, 1);
return;
});
}).catch(done);
}).then(function () {
return middleware.auth(req, res, null);
}).then(function () {
assert(res.redirect.calledWithMatch('/ghost/signin/?r=' + encodeURIComponent(path)));
return api.notifications.browse().then(function (notifications) {
assert.equal(notifications.length, 1);
return done();
});
done();
}).catch(done);
});
});
@ -75,7 +75,7 @@ describe('Middleware', function () {
middleware.auth(req, res, function (a) {
should.not.exist(a);
assert(res.redirect.calledOnce.should.be.false);
return done();
done();
});
});
});
@ -97,7 +97,7 @@ describe('Middleware', function () {
it('should return a json 401 error response', function (done) {
middleware.authAPI(req, res, null);
assert(res.json.calledWith(401, { error: 'Please sign in' }));
return done();
done();
});
it('should call next if a user exists in session', function (done) {
@ -106,7 +106,7 @@ describe('Middleware', function () {
middleware.authAPI(req, res, function (a) {
should.not.exist(a);
assert(res.redirect.calledOnce.should.be.false);
return done();
done();
});
});
});
@ -129,14 +129,14 @@ describe('Middleware', function () {
middleware.redirectToDashboard(req, res, null);
assert(res.redirect.calledWithMatch('/ghost/'));
return done();
done();
});
it('should call next if no user in session', function (done) {
middleware.redirectToDashboard(req, res, function (a) {
should.not.exist(a);
assert(res.redirect.calledOnce.should.be.false);
return done();
done();
});
});
});
@ -162,7 +162,7 @@ describe('Middleware', function () {
});
}).then(function () {
done();
});
}).catch(done);
});
it('should clean all passive messages', function (done) {
@ -173,8 +173,8 @@ describe('Middleware', function () {
return notification.status === 'passive';
});
assert.equal(passiveMsgs.length, 0);
return done();
});
done();
}).catch(done);
});
});
});
@ -193,7 +193,7 @@ describe('Middleware', function () {
should.not.exist(a);
res.set.calledOnce.should.be.true;
res.set.calledWith({'Cache-Control': 'public, max-age=0'});
return done();
done();
});
});
@ -202,7 +202,7 @@ describe('Middleware', function () {
should.not.exist(a);
res.set.calledOnce.should.be.true;
res.set.calledWith({'Cache-Control': 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'});
return done();
done();
});
});
@ -210,7 +210,7 @@ describe('Middleware', function () {
middleware.cacheControl()(null, res, function (a) {
should.not.exist(a);
res.set.called.should.be.false;
return done();
done();
});
});
});
@ -239,7 +239,7 @@ describe('Middleware', function () {
assert.equal(a, 1);
assert.equal(b, 2);
assert.equal(c, 3);
return done();
done();
})(req, res, next);
});
@ -247,7 +247,7 @@ describe('Middleware', function () {
middleware.whenEnabled('rando', cbFn)(null, null, function (a) {
should.not.exist(a);
cbFn.calledOnce.should.be.false;
return done();
done();
});
});
});
@ -269,7 +269,7 @@ describe('Middleware', function () {
middleware.staticTheme(null)(req, null, function (a) {
should.not.exist(a);
middleware.forwardToExpressStatic.calledOnce.should.be.false;
return done();
done();
});
});
@ -281,7 +281,7 @@ describe('Middleware', function () {
middleware.staticTheme(null)(req, null, function (a) {
should.not.exist(a);
middleware.forwardToExpressStatic.calledOnce.should.be.false;
return done();
done();
});
});
@ -293,7 +293,7 @@ describe('Middleware', function () {
middleware.staticTheme(null)(req, null, function (a) {
should.not.exist(a);
middleware.forwardToExpressStatic.calledOnce.should.be.false;
return done();
done();
});
});
@ -310,7 +310,7 @@ describe('Middleware', function () {
middleware.staticTheme(null)(req, null, function (reqArg, res, next) {
middleware.forwardToExpressStatic.calledOnce.should.be.true;
assert.deepEqual(middleware.forwardToExpressStatic.args[0][0], req);
return done();
done();
});
});
});

View File

@ -21,7 +21,7 @@ describe('Permissions', function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
beforeEach(function (done) {
@ -31,7 +31,7 @@ describe('Permissions', function () {
.then(testUtils.insertDefaultApp)
.then(function () {
done();
}, done);
}).catch(done);
});
afterEach(function (done) {
@ -39,13 +39,13 @@ describe('Permissions', function () {
testUtils.clearData()
.then(function () {
done();
}, done);
}).catch(done);
});
after(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
}).catch(done);
});
var testPerms = [
@ -109,7 +109,7 @@ describe('Permissions', function () {
actionsMap.should.equal(permissions.actionsMap);
done();
}).then(null, done);
}).catch(done);
});
it('can add user to role', function (done) {
@ -138,7 +138,7 @@ describe('Permissions', function () {
updatedUser.related('roles').length.should.equal(existingUserRoles + 1);
done();
}).then(null, done);
}).catch(done);
});
it('can add user permissions', function (done) {
@ -162,7 +162,7 @@ describe('Permissions', function () {
updatedUser.related('permissions').length.should.equal(1);
done();
}).then(null, done);
}).catch(done);
});
it('can add role permissions', function (done) {
@ -197,7 +197,7 @@ describe('Permissions', function () {
updatedRole.related('permissions').length.should.equal(1);
done();
}).then(null, done);
}).catch(done);
});
it('does not allow edit post without permission', function (done) {
@ -220,7 +220,7 @@ describe('Permissions', function () {
})
.then(function () {
errors.logError(new Error("Allowed edit post without permission"));
}, done);
}).catch(done);
});
it('allows edit post with permission', function (done) {
@ -259,7 +259,7 @@ describe('Permissions', function () {
})
.then(function () {
done();
}, done);
}).catch(done);
});
it('can use permissable function on Model to allow something', function (done) {
@ -283,7 +283,7 @@ describe('Permissions', function () {
done();
})
.otherwise(function () {
.catch(function () {
permissableStub.restore();
errors.logError(new Error("Did not allow testUser"));
@ -311,7 +311,7 @@ describe('Permissions', function () {
done(new Error("Allowed testUser to edit post"));
})
.otherwise(function () {
.catch(function () {
permissableStub.restore();
permissableStub.calledWith(123, { user: testUser.id, app: null, internal: false }).should.equal(true);
done();
@ -325,7 +325,7 @@ describe('Permissions', function () {
effectivePermissions.length.should.be.above(0);
done();
}).then(null, done);
}).catch(done);
});
it('can check an apps effective permissions', function (done) {
@ -337,7 +337,7 @@ describe('Permissions', function () {
done();
})
.otherwise(done);
.catch(done);
});
it('does not allow an app to edit a post without permission', function (done) {
@ -370,7 +370,7 @@ describe('Permissions', function () {
.then(function () {
return results;
})
.otherwise(function (err) {
.catch(function (err) {
done(new Error("Did not allow user 1 to edit post 1"));
});
})
@ -385,10 +385,10 @@ describe('Permissions', function () {
.then(function () {
done(new Error("Allowed an edit of post 1"));
})
.otherwise(function () {
.catch(function () {
done();
});
}).otherwise(done);
}).catch(done);
});
it('allows an app to edit a post with permission', function (done) {
@ -398,7 +398,7 @@ describe('Permissions', function () {
.then(function () {
done();
})
.otherwise(function () {
.catch(function () {
done(new Error("Allowed an edit of post 1"));
});
});
@ -410,7 +410,7 @@ describe('Permissions', function () {
.then(function () {
done(new Error("Should not allow editing post"));
})
.otherwise(function () {
.catch(function () {
done();
});
});
@ -423,7 +423,7 @@ describe('Permissions', function () {
.then(function () {
done();
})
.otherwise(function () {
.catch(function () {
done(new Error("Should allow editing post with 'internal'"));
});
});
@ -436,7 +436,7 @@ describe('Permissions', function () {
.then(function () {
done();
})
.otherwise(function () {
.catch(function () {
done(new Error("Should allow editing post with { internal: true }"));
});
});

View File

@ -292,7 +292,7 @@ describe('Core Helpers', function () {
rendered.string.should.equal('home-template');
done();
}).then(null, done);
}).catch(done);
});
it('can render class string for context', function (done) {
@ -318,7 +318,7 @@ describe('Core Helpers', function () {
rendered[4].string.should.equal('archive-template tag-template tag-foo');
done();
}).then(null, done);
}).catch(done);
});
it('can render class for static page', function (done) {
@ -332,7 +332,7 @@ describe('Core Helpers', function () {
rendered.string.should.equal('home-template page');
done();
}).then(null, done);
}).catch(done);
});
it('can render class for static page with custom template', function (done) {
@ -348,7 +348,7 @@ describe('Core Helpers', function () {
rendered.string.should.equal('post-template page page-template-about');
done();
}).then(null, done);
}).catch(done);
});
});
@ -362,7 +362,7 @@ describe('Core Helpers', function () {
should.exist(rendered);
rendered.string.should.equal('post');
done();
}).then(null, done);
}).catch(done);
});
it('can render featured class', function (done) {
@ -373,7 +373,7 @@ describe('Core Helpers', function () {
rendered.string.should.equal('post featured');
done();
}).then(null, done);
}).catch(done);
});
it('can render page class', function (done) {
@ -384,7 +384,7 @@ describe('Core Helpers', function () {
rendered.string.should.equal('post page');
done();
}).then(null, done);
}).catch(done);
});
});
@ -409,7 +409,7 @@ describe('Core Helpers', function () {
'<link rel="canonical" href="http://testurl.com/" />');
done();
}).then(null, done);
}).catch(done);
});
it('returns meta tag string even if version is invalid', function (done) {
@ -421,7 +421,7 @@ describe('Core Helpers', function () {
'<link rel="canonical" href="http://testurl.com/" />');
done();
}).then(null, done);
}).catch(done);
});
it('returns correct rss url with subdirectory', function (done) {
@ -433,7 +433,7 @@ describe('Core Helpers', function () {
'<link rel="canonical" href="http://testurl.com/blog/" />');
done();
}).then(null, done);
}).catch(done);
});
it('returns canonical URL', function (done) {
@ -445,7 +445,7 @@ describe('Core Helpers', function () {
'<link rel="canonical" href="http://testurl.com/about/" />');
done();
}).then(null, done);
}).catch(done);
});
});
@ -462,7 +462,7 @@ describe('Core Helpers', function () {
rendered.string.should.match(/<script src=".*\/public\/jquery.js\?v=abc"><\/script>/);
done();
}).then(null, done);
}).catch(done);
});
it('outputs correct jquery for production mode', function (done) {
@ -474,7 +474,7 @@ describe('Core Helpers', function () {
rendered.string.should.match(/<script src=".*\/public\/jquery.min.js\?v=abc"><\/script>/);
done();
}).then(null, done);
}).catch(done);
});
});
@ -872,7 +872,7 @@ describe('Core Helpers', function () {
rendered.string.should.equal('Ghost');
done();
}).then(null, done);
}).catch(done);
});
it('can return title of a post', function (done) {
@ -882,7 +882,7 @@ describe('Core Helpers', function () {
rendered.string.should.equal('Post Title');
done();
}).then(null, done);
}).catch(done);
});
it('can return tag name', function (done) {
@ -892,7 +892,7 @@ describe('Core Helpers', function () {
rendered.string.should.equal('foo - Ghost');
done();
}).then(null, done);
}).catch(done);
});
});
@ -908,7 +908,7 @@ describe('Core Helpers', function () {
rendered.string.should.equal('Just a blogging platform.');
done();
}).then(null, done);
}).catch(done);
});
it('can return empty description on post', function (done) {
@ -918,7 +918,7 @@ describe('Core Helpers', function () {
rendered.string.should.equal('');
done();
}).then(null, done);
}).catch(done);
});
});
@ -1206,7 +1206,7 @@ describe('Core Helpers', function () {
rendered.should.equal(classOutput);
done();
}).then(null, done);
}).catch(done);
});
it('does NOT output a correctly formatted notification when db version equals package version', function (done) {
@ -1219,7 +1219,7 @@ describe('Core Helpers', function () {
should.exist(rendered);
rendered.should.equal('');
done();
}).then(null, done);
}).catch(done);
});
it('does NOT output a notification if updateCheck is false', function (done) {
@ -1234,7 +1234,7 @@ describe('Core Helpers', function () {
should.exist(rendered);
rendered.should.equal('');
done();
}).then(null, done);
}).catch(done);
});
it('does NOT output a notification if the user is not logged in', function (done) {
@ -1249,7 +1249,7 @@ describe('Core Helpers', function () {
should.exist(rendered);
rendered.should.equal('');
done();
}).then(null, done);
}).catch(done);
});
});
});

View File

@ -39,7 +39,7 @@ describe('Local File System Storage', function () {
localfilesystem.save(image).then(function (url) {
url.should.equal('/content/images/2013/Sep/IMAGE.jpg');
return done();
}).then(null, done);
}).catch(done);
});
it('should send correct path to image when original file has spaces', function (done) {
@ -47,7 +47,7 @@ describe('Local File System Storage', function () {
localfilesystem.save(image).then(function (url) {
url.should.equal('/content/images/2013/Sep/AN-IMAGE.jpg');
return done();
}).then(null, done);
}).catch(done);
});
it('should send correct path to image when date is in Jan 2014', function (done) {
@ -56,7 +56,7 @@ describe('Local File System Storage', function () {
localfilesystem.save(image).then(function (url) {
url.should.equal('/content/images/2014/Jan/IMAGE.jpg');
return done();
}).then(null, done);
}).catch(done);
});
it('should create month and year directory', function (done) {
@ -64,7 +64,7 @@ describe('Local File System Storage', function () {
fs.mkdirs.calledOnce.should.be.true;
fs.mkdirs.args[0][0].should.equal(path.resolve('./content/images/2013/Sep'));
done();
}).then(null, done);
}).catch(done);
});
it('should copy temp file to new location', function (done) {
@ -73,7 +73,7 @@ describe('Local File System Storage', function () {
fs.copy.args[0][0].should.equal('tmp/123456.jpg');
fs.copy.args[0][1].should.equal(path.resolve('./content/images/2013/Sep/IMAGE.jpg'));
done();
}).then(null, done);
}).catch(done);
});
it('should not leave temporary file when uploading', function (done) {
@ -81,7 +81,7 @@ describe('Local File System Storage', function () {
fs.unlink.calledOnce.should.be.true;
fs.unlink.args[0][0].should.equal('tmp/123456.jpg');
done();
}).then(null, done);
}).catch(done);
});
it('can upload two different images with the same name without overwriting the first', function (done) {
@ -98,7 +98,7 @@ describe('Local File System Storage', function () {
localfilesystem.save(image).then(function (url) {
url.should.equal('/content/images/2013/Sep/IMAGE-1.jpg');
return done();
}).then(null, done);
}).catch(done);
});
it('can upload five different images with the same name without overwriting the first', function (done) {
@ -120,7 +120,7 @@ describe('Local File System Storage', function () {
localfilesystem.save(image).then(function (url) {
url.should.equal('/content/images/2013/Sep/IMAGE-4.jpg');
return done();
}).then(null, done);
}).catch(done);
});
describe('when a custom content path is used', function () {
@ -141,7 +141,7 @@ describe('Local File System Storage', function () {
localfilesystem.save(image).then(function (url) {
url.should.equal('/content/images/2013/Sep/IMAGE.jpg');
return done();
}).then(null, done);
}).catch(done);
});
});
@ -171,7 +171,7 @@ describe('Local File System Storage', function () {
path.normalize(url).should.equal('/content/images/2013/Sep/IMAGE.jpg');
}
return done();
}).then(null, done);
}).catch(done);
});
});
});

View File

@ -40,7 +40,7 @@ describe('XMLRPC', function () {
ping2.isDone().should.be.true;
done();
});
}).catch(done);
});
});