mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
analytics tests, reduce bcrypt rouds for tests
This commit is contained in:
@@ -6,7 +6,8 @@ var winston = require('winston');
|
|||||||
|
|
||||||
var db = require('./database');
|
var db = require('./database');
|
||||||
|
|
||||||
(function (Analytics) {
|
var Analytics = module.exports;
|
||||||
|
|
||||||
var counters = {};
|
var counters = {};
|
||||||
|
|
||||||
var pageViews = 0;
|
var pageViews = 0;
|
||||||
@@ -58,7 +59,8 @@ var db = require('./database');
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Analytics.writeData = function () {
|
Analytics.writeData = function (callback) {
|
||||||
|
callback = callback || function () {};
|
||||||
var today = new Date();
|
var today = new Date();
|
||||||
var month = new Date();
|
var month = new Date();
|
||||||
var dbQueue = [];
|
var dbQueue = [];
|
||||||
@@ -96,6 +98,7 @@ var db = require('./database');
|
|||||||
if (err) {
|
if (err) {
|
||||||
winston.error('[analytics] Encountered error while writing analytics to data store: ' + err.message);
|
winston.error('[analytics] Encountered error while writing analytics to data store: ' + err.message);
|
||||||
}
|
}
|
||||||
|
callback(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -194,4 +197,3 @@ var db = require('./database');
|
|||||||
}, callback);
|
}, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
}(exports));
|
|
||||||
@@ -45,6 +45,8 @@ describe('Controllers', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
it('should load default home route', function (done) {
|
it('should load default home route', function (done) {
|
||||||
request(nconf.get('url'), function (err, res, body) {
|
request(nconf.get('url'), function (err, res, body) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
@@ -615,6 +617,10 @@ describe('Controllers', function () {
|
|||||||
|
|
||||||
|
|
||||||
after(function (done) {
|
after(function (done) {
|
||||||
|
var analytics = require('../src/analytics');
|
||||||
|
analytics.writeData(function (err) {
|
||||||
|
assert.ifError(err);
|
||||||
db.emptydb(done);
|
db.emptydb(done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -129,6 +129,7 @@
|
|||||||
nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-persona/templates'));
|
nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-persona/templates'));
|
||||||
nconf.set('theme_templates_path', meta.config['theme:templates'] ? path.join(nconf.get('themes_path'), meta.config['theme:id'], meta.config['theme:templates']) : nconf.get('base_templates_path'));
|
nconf.set('theme_templates_path', meta.config['theme:templates'] ? path.join(nconf.get('themes_path'), meta.config['theme:id'], meta.config['theme:templates']) : nconf.get('base_templates_path'));
|
||||||
nconf.set('theme_config', path.join(nconf.get('themes_path'), 'nodebb-theme-persona', 'theme.json'));
|
nconf.set('theme_config', path.join(nconf.get('themes_path'), 'nodebb-theme-persona', 'theme.json'));
|
||||||
|
nconf.set('bcrypt_rounds', 6);
|
||||||
|
|
||||||
require('../../build').buildTargets(['js', 'clientCSS', 'acpCSS', 'tpl'], next);
|
require('../../build').buildTargets(['js', 'clientCSS', 'acpCSS', 'tpl'], next);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -322,6 +322,24 @@ describe('socket.io', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should get daily analytics', function (done) {
|
||||||
|
io.emit('admin.analytics.get', {graph: 'traffic', units: 'days'}, function (err, data) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert(data);
|
||||||
|
assert(data.monthlyPageViews);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should get hourly analytics', function (done) {
|
||||||
|
io.emit('admin.analytics.get', {graph: 'traffic', units: 'hours'}, function (err, data) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert(data);
|
||||||
|
assert(data.monthlyPageViews);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
after(function (done) {
|
after(function (done) {
|
||||||
db.emptydb(done);
|
db.emptydb(done);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user