Ghost/core/test/ghost/ghost_spec.js
Jacob Gable e6f7c706cb Permissions / ACL
- Created Role model
- Created Permission model
- Linked Users->Roles with a belongsToMany relationship
- Linked Permissions to Users and Roles with a belongsToMany relationship
- Created permissions helper with functions for initializing and
  checking permissions (canThis)
- Unit tests for lots of things
2013-06-06 08:15:10 +01:00

51 lines
1.3 KiB
JavaScript

/*globals describe, beforeEach, it*/
(function () {
"use strict";
var should = require('should'),
when = require('when'),
sinon = require('sinon'),
Ghost = require('../../ghost');
describe("Ghost API", function () {
it("is a singleton", function () {
var logStub = sinon.stub(console, "log"),
ghost1 = new Ghost(),
ghost2 = new Ghost();
should.strictEqual(ghost1, ghost2);
logStub.restore();
});
it("uses init() to initialize", function (done) {
var ghost = new Ghost(),
fakeDataProvider = {
init: function () {
return when.resolve();
}
},
dataProviderInitSpy = sinon.spy(fakeDataProvider, "init"),
oldDataProvder = ghost.dataProvider;
ghost.dataProvider = fakeDataProvider;
should.not.exist(ghost.globals());
ghost.init().then(function () {
should.exist(ghost.globals());
dataProviderInitSpy.called.should.equal(true);
ghost.dataProvider = oldDataProvder;
done();
}).then(null, done);
});
});
}());