mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Patch to prevent timeouts in unit tests
Temporary patch for #362 - Split out database teardown and initialization so they each have their own 2 second timeout. - Added some test-specific increased timeouts.
This commit is contained in:
parent
9d8bf4b0f9
commit
ff3a9dde00
9 changed files with 291 additions and 192 deletions
|
@ -176,6 +176,10 @@ var path = require('path'),
|
||||||
src: ['core/test/unit/**/api*_spec.js']
|
src: ['core/test/unit/**/api*_spec.js']
|
||||||
},
|
},
|
||||||
|
|
||||||
|
frontend: {
|
||||||
|
src: ['core/test/unit/**/frontend*_spec.js']
|
||||||
|
},
|
||||||
|
|
||||||
perm: {
|
perm: {
|
||||||
src: ['core/test/unit/**/permissions_spec.js']
|
src: ['core/test/unit/**/permissions_spec.js']
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,8 +10,21 @@ describe("Role Model", function () {
|
||||||
|
|
||||||
should.exist(RoleModel);
|
should.exist(RoleModel);
|
||||||
|
|
||||||
|
before(function (done) {
|
||||||
|
helpers.clearData().then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
helpers.resetData().then(function () {
|
this.timeout(5000);
|
||||||
|
helpers.initData().then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function (done) {
|
||||||
|
helpers.clearData().then(function () {
|
||||||
done();
|
done();
|
||||||
}, done);
|
}, done);
|
||||||
});
|
});
|
||||||
|
@ -91,8 +104,21 @@ describe("Permission Model", function () {
|
||||||
|
|
||||||
should.exist(PermissionModel);
|
should.exist(PermissionModel);
|
||||||
|
|
||||||
|
before(function (done) {
|
||||||
|
helpers.clearData().then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
helpers.resetData().then(function () {
|
this.timeout(5000);
|
||||||
|
helpers.initData().then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function (done) {
|
||||||
|
helpers.clearData().then(function () {
|
||||||
done();
|
done();
|
||||||
}, done);
|
}, done);
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,10 +9,32 @@ var _ = require("underscore"),
|
||||||
describe('Post Model', function () {
|
describe('Post Model', function () {
|
||||||
|
|
||||||
var PostModel = Models.Post,
|
var PostModel = Models.Post,
|
||||||
UserModel = Models.User;
|
UserModel = Models.User,
|
||||||
|
userData = {
|
||||||
|
password: 'testpass1',
|
||||||
|
email_address: "test@test1.com",
|
||||||
|
full_name: "Mr Biscuits"
|
||||||
|
};
|
||||||
|
|
||||||
|
before(function (done) {
|
||||||
|
helpers.clearData().then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
helpers.resetData().then(function () {
|
this.timeout(5000);
|
||||||
|
helpers.initData()
|
||||||
|
.then(function () {
|
||||||
|
return UserModel.add(userData);
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function (done) {
|
||||||
|
helpers.clearData().then(function () {
|
||||||
done();
|
done();
|
||||||
}, done);
|
}, done);
|
||||||
});
|
});
|
||||||
|
@ -48,62 +70,36 @@ describe('Post Model', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can findAll, returning author and user data', function (done) {
|
it('can findAll, returning author and user data', function (done) {
|
||||||
var firstPost,
|
var firstPost;
|
||||||
userData = {
|
|
||||||
password: 'testpass1',
|
|
||||||
email_address: "test@test1.com",
|
|
||||||
full_name: "Mr Biscuits"
|
|
||||||
};
|
|
||||||
|
|
||||||
helpers.resetData().then(function () {
|
PostModel.findAll({}).then(function (results) {
|
||||||
UserModel.add(userData).then(function (createdUser) {
|
should.exist(results);
|
||||||
|
results.length.should.be.above(0);
|
||||||
|
firstPost = results.models[0].toJSON();
|
||||||
|
|
||||||
PostModel.findAll({}).then(function (results) {
|
firstPost.author.should.be.a("object");
|
||||||
should.exist(results);
|
firstPost.user.should.be.a("object");
|
||||||
results.length.should.be.above(0);
|
firstPost.author.full_name.should.equal("Mr Biscuits");
|
||||||
firstPost = results.models[0].toJSON();
|
firstPost.user.full_name.should.equal("Mr Biscuits");
|
||||||
|
|
||||||
firstPost.author.should.be.a("object");
|
done();
|
||||||
firstPost.user.should.be.a("object");
|
}, done);
|
||||||
firstPost.author.full_name.should.equal("Mr Biscuits");
|
|
||||||
firstPost.user.full_name.should.equal("Mr Biscuits");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}).then(null, done);
|
|
||||||
|
|
||||||
done();
|
|
||||||
}).then(null, done);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can findOne, returning author and user data', function (done) {
|
it('can findOne, returning author and user data', function (done) {
|
||||||
var firstPost,
|
var firstPost;
|
||||||
userData = {
|
|
||||||
password: 'testpass1',
|
|
||||||
email_address: "test@test1.com",
|
|
||||||
full_name: "Mr Biscuits"
|
|
||||||
};
|
|
||||||
|
|
||||||
helpers.resetData().then(function () {
|
PostModel.findOne({}).then(function (result) {
|
||||||
UserModel.add(userData).then(function (createdUser) {
|
should.exist(result);
|
||||||
|
firstPost = result.toJSON();
|
||||||
|
|
||||||
PostModel.findOne({}).then(function (result) {
|
firstPost.author.should.be.a("object");
|
||||||
should.exist(result);
|
firstPost.user.should.be.a("object");
|
||||||
firstPost = result.toJSON();
|
firstPost.author.full_name.should.equal("Mr Biscuits");
|
||||||
|
firstPost.user.full_name.should.equal("Mr Biscuits");
|
||||||
|
|
||||||
firstPost.author.should.be.a("object");
|
done();
|
||||||
firstPost.user.should.be.a("object");
|
}, done);
|
||||||
firstPost.author.full_name.should.equal("Mr Biscuits");
|
|
||||||
firstPost.user.full_name.should.equal("Mr Biscuits");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}).then(null, done);
|
|
||||||
|
|
||||||
done();
|
|
||||||
}).then(null, done);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can edit', function (done) {
|
it('can edit', function (done) {
|
||||||
|
@ -172,7 +168,9 @@ describe('Post Model', function () {
|
||||||
content_raw: 'Test Content 1'
|
content_raw: 'Test Content 1'
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create 12 posts with the sametitle
|
this.timeout(5000); // this is a patch to ensure it doesn't timeout.
|
||||||
|
|
||||||
|
// Create 12 posts with the same title
|
||||||
sequence(_.times(12, function (i) {
|
sequence(_.times(12, function (i) {
|
||||||
return function () {
|
return function () {
|
||||||
return PostModel.add({
|
return PostModel.add({
|
||||||
|
@ -241,7 +239,7 @@ describe('Post Model', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can fetch a paginated set, with various options', function (done) {
|
it('can fetch a paginated set, with various options', function (done) {
|
||||||
this.timeout(5000);
|
this.timeout(10000); // this is a patch to ensure it doesn't timeout.
|
||||||
|
|
||||||
helpers.insertMorePosts().then(function () {
|
helpers.insertMorePosts().then(function () {
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,21 @@ describe('Settings Model', function () {
|
||||||
|
|
||||||
var SettingsModel = Models.Settings;
|
var SettingsModel = Models.Settings;
|
||||||
|
|
||||||
|
before(function (done) {
|
||||||
|
helpers.clearData().then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
helpers.resetData().then(function () {
|
this.timeout(5000);
|
||||||
|
helpers.initData().then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function (done) {
|
||||||
|
helpers.clearData().then(function () {
|
||||||
done();
|
done();
|
||||||
}, done);
|
}, done);
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,25 +6,35 @@ var _ = require('underscore'),
|
||||||
Models = require('../../server/models');
|
Models = require('../../server/models');
|
||||||
when = require('when');
|
when = require('when');
|
||||||
|
|
||||||
describe('User Model', function () {
|
describe('User Model', function run() {
|
||||||
|
|
||||||
var UserModel = Models.User;
|
var UserModel = Models.User;
|
||||||
|
|
||||||
beforeEach(function (done) {
|
before(function (done) {
|
||||||
helpers.resetData().then(function () {
|
helpers.clearData().then(function () {
|
||||||
return when(helpers.insertDefaultUser());
|
|
||||||
}).then(function () {
|
|
||||||
done();
|
done();
|
||||||
}, done);
|
}, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can add first', function (done) {
|
afterEach(function (done) {
|
||||||
var userData = {
|
helpers.clearData().then(function () {
|
||||||
password: 'testpass1',
|
done();
|
||||||
email_address: "test@test1.com"
|
}, done);
|
||||||
};
|
});
|
||||||
|
|
||||||
|
describe('Registration', function runRegistration() {
|
||||||
|
beforeEach(function (done) {
|
||||||
|
this.timeout(5000);
|
||||||
|
helpers.initData().then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can add first', function (done) {
|
||||||
|
var userData = {
|
||||||
|
password: 'testpass1',
|
||||||
|
email_address: "test@test1.com"
|
||||||
|
};
|
||||||
|
|
||||||
helpers.resetData().then(function () {
|
|
||||||
UserModel.add(userData).then(function (createdUser) {
|
UserModel.add(userData).then(function (createdUser) {
|
||||||
should.exist(createdUser);
|
should.exist(createdUser);
|
||||||
createdUser.has('uuid').should.equal(true);
|
createdUser.has('uuid').should.equal(true);
|
||||||
|
@ -36,122 +46,139 @@ describe('User Model', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can\'t add second', function (done) {
|
describe('Basic Operations', function () {
|
||||||
var userData = {
|
|
||||||
password: 'testpass3',
|
|
||||||
email_address: "test3@test1.com"
|
|
||||||
};
|
|
||||||
|
|
||||||
return UserModel.add(userData).then(done, function (failure) {
|
beforeEach(function (done) {
|
||||||
failure.message.should.eql('A user is already registered. Only one user for now!');
|
this.timeout(5000);
|
||||||
done();
|
helpers.initData()
|
||||||
}).then(null, done);
|
.then(function () {
|
||||||
});
|
return when(helpers.insertDefaultUser());
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
it('can browse', function (done) {
|
it('can\'t add second', function (done) {
|
||||||
|
var userData = {
|
||||||
|
password: 'testpass3',
|
||||||
|
email_address: "test3@test1.com"
|
||||||
|
};
|
||||||
|
|
||||||
UserModel.browse().then(function (results) {
|
return helpers.insertDefaultUser().then(function () {
|
||||||
should.exist(results);
|
UserModel.add(userData).then(done, function (failure) {
|
||||||
|
failure.message.should.eql('A user is already registered. Only one user for now!');
|
||||||
results.length.should.be.above(0);
|
done();
|
||||||
|
}).then(null, done);
|
||||||
done();
|
|
||||||
|
|
||||||
}).then(null, done);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can read', function (done) {
|
|
||||||
var firstUser;
|
|
||||||
|
|
||||||
UserModel.browse().then(function (results) {
|
|
||||||
|
|
||||||
should.exist(results);
|
|
||||||
|
|
||||||
results.length.should.be.above(0);
|
|
||||||
|
|
||||||
firstUser = results.models[0];
|
|
||||||
|
|
||||||
return UserModel.read({email_address: firstUser.attributes.email_address});
|
|
||||||
|
|
||||||
}).then(function (found) {
|
|
||||||
|
|
||||||
should.exist(found);
|
|
||||||
|
|
||||||
found.attributes.full_name.should.equal(firstUser.attributes.full_name);
|
|
||||||
|
|
||||||
done();
|
|
||||||
|
|
||||||
}).then(null, done);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can edit', function (done) {
|
|
||||||
var firstUser;
|
|
||||||
|
|
||||||
UserModel.browse().then(function (results) {
|
|
||||||
|
|
||||||
should.exist(results);
|
|
||||||
|
|
||||||
results.length.should.be.above(0);
|
|
||||||
|
|
||||||
firstUser = results.models[0];
|
|
||||||
|
|
||||||
return UserModel.edit({id: firstUser.id, url: "some.newurl.com"});
|
|
||||||
|
|
||||||
}).then(function (edited) {
|
|
||||||
|
|
||||||
should.exist(edited);
|
|
||||||
|
|
||||||
edited.attributes.url.should.equal('some.newurl.com');
|
|
||||||
|
|
||||||
done();
|
|
||||||
|
|
||||||
}).then(null, done);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("can get effective permissions", function (done) {
|
|
||||||
UserModel.effectivePermissions(1).then(function (effectivePermissions) {
|
|
||||||
should.exist(effectivePermissions);
|
|
||||||
|
|
||||||
effectivePermissions.length.should.be.above(0);
|
|
||||||
|
|
||||||
done();
|
|
||||||
}).then(null, done);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can delete', function (done) {
|
|
||||||
var firstUserId;
|
|
||||||
|
|
||||||
UserModel.browse().then(function (results) {
|
|
||||||
|
|
||||||
should.exist(results);
|
|
||||||
|
|
||||||
results.length.should.be.above(0);
|
|
||||||
|
|
||||||
firstUserId = results.models[0].id;
|
|
||||||
|
|
||||||
return UserModel.destroy(firstUserId);
|
|
||||||
|
|
||||||
}).then(function () {
|
|
||||||
|
|
||||||
return UserModel.browse();
|
|
||||||
|
|
||||||
}).then(function (newResults) {
|
|
||||||
var ids, hasDeletedId;
|
|
||||||
|
|
||||||
if (newResults.length < 1) {
|
|
||||||
// Bug out if we only had one user and deleted it.
|
|
||||||
return done();
|
|
||||||
}
|
|
||||||
|
|
||||||
ids = _.pluck(newResults.models, "id");
|
|
||||||
hasDeletedId = _.any(ids, function (id) {
|
|
||||||
return id === firstUserId;
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
hasDeletedId.should.equal(false);
|
it('can browse', function (done) {
|
||||||
done();
|
|
||||||
|
|
||||||
}).then(null, done);
|
UserModel.browse().then(function (results) {
|
||||||
|
should.exist(results);
|
||||||
|
|
||||||
|
results.length.should.be.above(0);
|
||||||
|
|
||||||
|
done();
|
||||||
|
|
||||||
|
}).then(null, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can read', function (done) {
|
||||||
|
var firstUser;
|
||||||
|
|
||||||
|
UserModel.browse().then(function (results) {
|
||||||
|
|
||||||
|
should.exist(results);
|
||||||
|
|
||||||
|
results.length.should.be.above(0);
|
||||||
|
|
||||||
|
firstUser = results.models[0];
|
||||||
|
|
||||||
|
return UserModel.read({email_address: firstUser.attributes.email_address});
|
||||||
|
|
||||||
|
}).then(function (found) {
|
||||||
|
|
||||||
|
should.exist(found);
|
||||||
|
|
||||||
|
found.attributes.full_name.should.equal(firstUser.attributes.full_name);
|
||||||
|
|
||||||
|
done();
|
||||||
|
|
||||||
|
}).then(null, done);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can edit', function (done) {
|
||||||
|
var firstUser;
|
||||||
|
|
||||||
|
UserModel.browse().then(function (results) {
|
||||||
|
|
||||||
|
should.exist(results);
|
||||||
|
|
||||||
|
results.length.should.be.above(0);
|
||||||
|
|
||||||
|
firstUser = results.models[0];
|
||||||
|
|
||||||
|
return UserModel.edit({id: firstUser.id, url: "some.newurl.com"});
|
||||||
|
|
||||||
|
}).then(function (edited) {
|
||||||
|
|
||||||
|
should.exist(edited);
|
||||||
|
|
||||||
|
edited.attributes.url.should.equal('some.newurl.com');
|
||||||
|
|
||||||
|
done();
|
||||||
|
|
||||||
|
}).then(null, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("can get effective permissions", function (done) {
|
||||||
|
UserModel.effectivePermissions(1).then(function (effectivePermissions) {
|
||||||
|
should.exist(effectivePermissions);
|
||||||
|
|
||||||
|
effectivePermissions.length.should.be.above(0);
|
||||||
|
|
||||||
|
done();
|
||||||
|
}).then(null, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can delete', function (done) {
|
||||||
|
var firstUserId;
|
||||||
|
|
||||||
|
UserModel.browse().then(function (results) {
|
||||||
|
|
||||||
|
should.exist(results);
|
||||||
|
|
||||||
|
results.length.should.be.above(0);
|
||||||
|
|
||||||
|
firstUserId = results.models[0].id;
|
||||||
|
|
||||||
|
return UserModel.destroy(firstUserId);
|
||||||
|
|
||||||
|
}).then(function () {
|
||||||
|
|
||||||
|
return UserModel.browse();
|
||||||
|
|
||||||
|
}).then(function (newResults) {
|
||||||
|
var ids, hasDeletedId;
|
||||||
|
|
||||||
|
if (newResults.length < 1) {
|
||||||
|
// Bug out if we only had one user and deleted it.
|
||||||
|
return done();
|
||||||
|
}
|
||||||
|
|
||||||
|
ids = _.pluck(newResults.models, "id");
|
||||||
|
hasDeletedId = _.any(ids, function (id) {
|
||||||
|
return id === firstUserId;
|
||||||
|
});
|
||||||
|
|
||||||
|
hasDeletedId.should.equal(false);
|
||||||
|
done();
|
||||||
|
|
||||||
|
}).then(null, done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
|
@ -224,7 +224,8 @@ describe('Core Helpers', function () {
|
||||||
helpers.loadCoreHelpers(ghost).then(function () {
|
helpers.loadCoreHelpers(ghost).then(function () {
|
||||||
rendered = handlebars.helpers.pagination.call({pagination: {page: 1, prev: undefined, next: undefined, limit: 15, total: 8, pages: 1}});
|
rendered = handlebars.helpers.pagination.call({pagination: {page: 1, prev: undefined, next: undefined, limit: 15, total: 8, pages: 1}});
|
||||||
should.exist(rendered);
|
should.exist(rendered);
|
||||||
rendered.string.should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="page-number">Page 1<span class="extended"> of 1</span></div>\n \n</nav>');
|
// strip out carriage returns and compare.
|
||||||
|
rendered.string.replace(/\r/g, '').should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="page-number">Page 1<span class="extended"> of 1</span></div>\n \n</nav>');
|
||||||
done();
|
done();
|
||||||
}).then(null, done);
|
}).then(null, done);
|
||||||
});
|
});
|
||||||
|
@ -234,7 +235,8 @@ describe('Core Helpers', function () {
|
||||||
helpers.loadCoreHelpers(ghost).then(function () {
|
helpers.loadCoreHelpers(ghost).then(function () {
|
||||||
rendered = handlebars.helpers.pagination.call({pagination: {page: 1, prev: undefined, next: 2, limit: 15, total: 8, pages: 3}});
|
rendered = handlebars.helpers.pagination.call({pagination: {page: 1, prev: undefined, next: 2, limit: 15, total: 8, pages: 3}});
|
||||||
should.exist(rendered);
|
should.exist(rendered);
|
||||||
rendered.string.should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="previous-page"><a href="/page/2/">Older Posts →</a></div>\n \n <div class="page-number">Page 1<span class="extended"> of 3</span></div>\n \n</nav>');
|
// strip out carriage returns and compare.
|
||||||
|
rendered.string.replace(/\r/g, '').should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="previous-page"><a href="/page/2/">Older Posts →</a></div>\n \n <div class="page-number">Page 1<span class="extended"> of 3</span></div>\n \n</nav>');
|
||||||
done();
|
done();
|
||||||
}).then(null, done);
|
}).then(null, done);
|
||||||
});
|
});
|
||||||
|
@ -244,7 +246,8 @@ describe('Core Helpers', function () {
|
||||||
helpers.loadCoreHelpers(ghost).then(function () {
|
helpers.loadCoreHelpers(ghost).then(function () {
|
||||||
rendered = handlebars.helpers.pagination.call({pagination: {page: 2, prev: 1, next: 3, limit: 15, total: 8, pages: 3}});
|
rendered = handlebars.helpers.pagination.call({pagination: {page: 2, prev: 1, next: 3, limit: 15, total: 8, pages: 3}});
|
||||||
should.exist(rendered);
|
should.exist(rendered);
|
||||||
rendered.string.should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="previous-page"><a href="/page/3/">Older Posts →</a></div>\n \n <div class="page-number">Page 2<span class="extended"> of 3</span></div>\n \n <div class="next-page"><a href="/page/1/">← Newer Posts</a></div>\n \n</nav>');
|
// strip out carriage returns and compare.
|
||||||
|
rendered.string.replace(/\r/g, '').should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="previous-page"><a href="/page/3/">Older Posts →</a></div>\n \n <div class="page-number">Page 2<span class="extended"> of 3</span></div>\n \n <div class="next-page"><a href="/page/1/">← Newer Posts</a></div>\n \n</nav>');
|
||||||
done();
|
done();
|
||||||
}).then(null, done);
|
}).then(null, done);
|
||||||
});
|
});
|
||||||
|
@ -254,7 +257,8 @@ describe('Core Helpers', function () {
|
||||||
helpers.loadCoreHelpers(ghost).then(function () {
|
helpers.loadCoreHelpers(ghost).then(function () {
|
||||||
rendered = handlebars.helpers.pagination.call({pagination: {page: 3, prev: 2, next: undefined, limit: 15, total: 8, pages: 3}});
|
rendered = handlebars.helpers.pagination.call({pagination: {page: 3, prev: 2, next: undefined, limit: 15, total: 8, pages: 3}});
|
||||||
should.exist(rendered);
|
should.exist(rendered);
|
||||||
rendered.string.should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="page-number">Page 3<span class="extended"> of 3</span></div>\n \n <div class="next-page"><a href="/page/2/">← Newer Posts</a></div>\n \n</nav>');
|
// strip out carriage returns and compare.
|
||||||
|
rendered.string.replace(/\r/g, '').should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="page-number">Page 3<span class="extended"> of 3</span></div>\n \n <div class="next-page"><a href="/page/2/">← Newer Posts</a></div>\n \n</nav>');
|
||||||
done();
|
done();
|
||||||
}).then(null, done);
|
}).then(null, done);
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,11 +42,9 @@ sampleUserRole = function (i) {
|
||||||
};
|
};
|
||||||
|
|
||||||
helpers = {
|
helpers = {
|
||||||
resetData: function () {
|
|
||||||
|
|
||||||
return this.clearData().then(function () {
|
initData: function (done) {
|
||||||
return migration.init();
|
return migration.init();
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
clearData: function () {
|
clearData: function () {
|
||||||
|
@ -54,7 +52,6 @@ helpers = {
|
||||||
return migration.migrateDownFromVersion(migration.currentVersion);
|
return migration.migrateDownFromVersion(migration.currentVersion);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
insertMorePosts: function () {
|
insertMorePosts: function () {
|
||||||
var lang, status, posts, promises = [], i, j;
|
var lang, status, posts, promises = [], i, j;
|
||||||
for (i = 0; i < 2; i += 1) {
|
for (i = 0; i < 2; i += 1) {
|
||||||
|
@ -69,6 +66,7 @@ helpers = {
|
||||||
}
|
}
|
||||||
return when.all(promises);
|
return when.all(promises);
|
||||||
},
|
},
|
||||||
|
|
||||||
insertDefaultUser: function () {
|
insertDefaultUser: function () {
|
||||||
|
|
||||||
var users = [],
|
var users = [],
|
||||||
|
@ -82,6 +80,7 @@ helpers = {
|
||||||
|
|
||||||
return when.all(u_promises);
|
return when.all(u_promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = helpers;
|
module.exports = helpers;
|
|
@ -13,12 +13,27 @@ var _ = require("underscore"),
|
||||||
|
|
||||||
describe('permissions', function () {
|
describe('permissions', function () {
|
||||||
|
|
||||||
|
before(function (done) {
|
||||||
|
helpers.clearData()
|
||||||
|
.then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
helpers.resetData().then(function () {
|
this.timeout(5000);
|
||||||
return helpers.insertDefaultUser();
|
helpers.initData()
|
||||||
}).then(function () {
|
.then(helpers.insertDefaultUser)
|
||||||
done();
|
.then(function () {
|
||||||
}, done);
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function (done) {
|
||||||
|
helpers.clearData()
|
||||||
|
.then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
var testPerms = [
|
var testPerms = [
|
||||||
|
|
|
@ -12,7 +12,20 @@ var _ = require("underscore"),
|
||||||
describe('Plugins', function () {
|
describe('Plugins', function () {
|
||||||
|
|
||||||
before(function (done) {
|
before(function (done) {
|
||||||
helpers.resetData().then(function () {
|
helpers.clearData().then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(function (done) {
|
||||||
|
this.timeout(5000);
|
||||||
|
helpers.initData().then(function () {
|
||||||
|
done();
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function (done) {
|
||||||
|
helpers.clearData().then(function () {
|
||||||
done();
|
done();
|
||||||
}, done);
|
}, done);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue