2016-04-08 13:39:50 +03:00
|
|
|
var testUtils = require('../utils'),
|
|
|
|
should = require('should'),
|
|
|
|
rewire = require('rewire'),
|
2014-07-21 21:50:04 +04:00
|
|
|
|
|
|
|
// Stuff we are testing
|
2016-04-08 13:39:50 +03:00
|
|
|
packageInfo = require('../../../package'),
|
|
|
|
updateCheck = rewire('../../server/update-check');
|
2014-05-04 05:30:30 +04:00
|
|
|
|
|
|
|
describe('Update Check', function () {
|
|
|
|
var environmentsOrig;
|
|
|
|
|
2014-07-30 02:29:13 +04:00
|
|
|
before(function () {
|
2014-05-04 05:30:30 +04:00
|
|
|
environmentsOrig = updateCheck.__get__('allowedCheckEnvironments');
|
|
|
|
updateCheck.__set__('allowedCheckEnvironments', ['development', 'production', 'testing']);
|
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
|
|
|
updateCheck.__set__('allowedCheckEnvironments', environmentsOrig);
|
|
|
|
});
|
|
|
|
|
2016-04-08 13:39:50 +03:00
|
|
|
beforeEach(testUtils.setup('owner', 'posts', 'perms:setting', 'perms:user', 'perms:init'));
|
2014-05-04 05:30:30 +04:00
|
|
|
|
2014-07-21 13:29:03 +04:00
|
|
|
afterEach(testUtils.teardown);
|
2014-05-04 05:30:30 +04:00
|
|
|
|
|
|
|
it('should report the correct data', function (done) {
|
|
|
|
var updateCheckData = updateCheck.__get__('updateCheckData');
|
|
|
|
|
|
|
|
updateCheckData().then(function (data) {
|
2014-05-07 04:49:25 +04:00
|
|
|
should.exist(data);
|
2014-05-04 05:30:30 +04:00
|
|
|
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/);
|
2016-02-08 00:27:01 +03:00
|
|
|
data.blog_id.should.be.a.String();
|
|
|
|
data.blog_id.should.not.be.empty();
|
2014-05-04 05:30:30 +04:00
|
|
|
data.theme.should.be.equal('casper');
|
2016-02-08 00:27:01 +03:00
|
|
|
data.apps.should.be.a.String();
|
|
|
|
data.blog_created_at.should.be.a.Number();
|
2014-05-04 05:30:30 +04:00
|
|
|
data.user_count.should.be.above(0);
|
|
|
|
data.post_count.should.be.above(0);
|
2016-02-08 00:27:01 +03:00
|
|
|
data.npm_version.should.be.a.String();
|
|
|
|
data.npm_version.should.not.be.empty();
|
2014-05-04 05:30:30 +04:00
|
|
|
|
|
|
|
done();
|
2014-05-07 04:49:25 +04:00
|
|
|
}).catch(done);
|
2014-05-04 05:30:30 +04:00
|
|
|
});
|
|
|
|
});
|