0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Fix role fixture ordering bug in pg tests

closes #6605

- ensure that roles are being output in order of their ID before asserting
- the asserting checks both the content and order of the array - this could be done differently as order doesn't really matter here, but will let us know if there are changes in DB behaviour
This commit is contained in:
Hannah Wolfe 2016-03-15 18:27:03 +00:00
parent 0c483a0997
commit 051a917e37

View file

@ -18,6 +18,8 @@ describe('Database Migration (special functions)', function () {
});
describe('Fixtures', function () {
beforeEach(testUtils.setup());
// Custom assertion for detection that a permissions is assigned to the correct roles
should.Assertion.add('AssignedToRoles', function (roles) {
var roleNames;
@ -27,7 +29,9 @@ describe('Database Migration (special functions)', function () {
this.obj.should.be.an.Object().with.property(['roles']);
this.obj.roles.should.be.an.Array();
roleNames = _.pluck(this.obj.roles, 'name');
// Ensure the roles are in id order
roleNames = _(this.obj.roles).sortBy('id').pluck('name').value();
roleNames.should.eql(roles);
});
@ -117,8 +121,6 @@ describe('Database Migration (special functions)', function () {
permissions[29].should.be.AssignedToRoles(['Administrator', 'Editor', 'Author']);
});
beforeEach(testUtils.setup());
it('should populate all fixtures correctly', function (done) {
var logStub = sandbox.stub();