Ghost/core/test/integration/update_check_spec.js
Hannah Wolfe 337713ce63 Refactor fixture use in tests
no issue

- Refactor all integration tests to specify and load ONLY the fixtures
  they require to run, rather than initialising the whole kit-and-kaboodle
  for every single test which takes FOREVER.
- Refactor the route tests to share a doAuth function, and also specify
  additional fixtures required
- Move import and export unit tests, which are actually integration tests
  (they touch the DB)
- Comment out most of the permissions unit tests for now as they need more
  stubs/mocks so as to not touch the DB

Still todo:

- prevent default DB initialisation in route tests, and specify all
  fixtures requires as per the integration tests
- fix up the unit/permissions_spec
2014-07-23 05:04:50 +01:00

65 lines
2.3 KiB
JavaScript

/*globals describe, before, beforeEach, afterEach, after, it*/
/*jshint expr:true*/
var testUtils = require('../utils'),
should = require('should'),
rewire = require('rewire'),
_ = require('lodash'),
// Stuff we are testing
packageInfo = require('../../../package'),
ghost = require('../../../core'),
config = rewire('../../../core/server/config'),
defaultConfig = require('../../../config.example')[process.env.NODE_ENV],
updateCheck = rewire('../../server/update-check');
describe('Update Check', function () {
var environmentsOrig;
before(function (done) {
environmentsOrig = updateCheck.__get__('allowedCheckEnvironments');
updateCheck.__set__('allowedCheckEnvironments', ['development', 'production', 'testing']);
_.extend(config, defaultConfig);
ghost({config: config.paths.config}).then(function () {
return testUtils.clearData();
}).then(function () {
done();
}).catch(function (err) {
console.log('Update Check before error', err);
throw new Error(err);
});
});
after(function () {
updateCheck.__set__('allowedCheckEnvironments', environmentsOrig);
});
beforeEach(testUtils.setup('owner', 'posts'));
afterEach(testUtils.teardown);
it('should report the correct data', function (done) {
var updateCheckData = updateCheck.__get__('updateCheckData');
updateCheckData().then(function (data) {
should.exist(data);
data.ghost_version.should.equal(packageInfo.version);
data.node_version.should.equal(process.versions.node);
data.env.should.equal(process.env.NODE_ENV);
data.database_type.should.match(/sqlite3|pg|mysql/);
data.blog_id.should.be.a.string;
data.blog_id.should.not.be.empty;
data.theme.should.be.equal('casper');
data.apps.should.be.a.string;
data.blog_created_at.should.be.a.number;
data.user_count.should.be.above(0);
data.post_count.should.be.above(0);
data.npm_version.should.be.a.string;
data.npm_version.should.not.be.empty;
done();
}).catch(done);
});
});