Merge branch 'master' of github.com:designcreateplay/NodeBB

v1.18.x
Julian Lam 11 years ago
commit 1f23642ab4

@ -55,23 +55,29 @@
nconf.set(dbType, testDbConfig); nconf.set(dbType, testDbConfig);
db = require('../src/database'); var db = require('../src/database'),
meta = require('../src/meta');
before(function(done) { before(function(done) {
db.init(function(err) { db.init(function(err) {
//Clean up //Clean up
db.flushdb(function(err) { db.flushdb(function(err) {
if(err){ if(err) {
winston.error(err); winston.error(err);
throw new Error(err); throw new Error(err);
} else {
winston.info('test_database flushed');
done();
} }
//TODO: data seeding, if needed at all winston.info('test_database flushed');
meta.configs.init(function () {
var webserver = require('../src/webserver'),
sockets = require('../src/socket.io');
sockets.init(webserver.server);
done();
});
}); });
}); });
}); });

@ -52,7 +52,7 @@ define(function() {
return false; return false;
}); });
$('#content input').focus(); $('#content #username').focus();
}; };
return Login; return Login;

@ -622,7 +622,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
socket.on('get_users_in_room', function(data) { socket.on('get_users_in_room', function(data) {
if(data && data.room.indexOf('topic') !== -1) { if(data && data.room.indexOf('topic') !== -1) {
var activeEl = $('li.post-bar[data-index="0"] .thread_active_users'); var activeEl = $('.thread_active_users');
function createUserIcon(uid, picture, userslug, username) { function createUserIcon(uid, picture, userslug, username) {
if(!activeEl.find('[data-uid="' + uid + '"]').length) { if(!activeEl.find('[data-uid="' + uid + '"]').length) {
@ -694,11 +694,9 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
// Get users who are currently replying to the topic entered // Get users who are currently replying to the topic entered
socket.emit('modules.composer.getUsersByTid', templates.get('topic_id'), function(err, uids) { socket.emit('modules.composer.getUsersByTid', templates.get('topic_id'), function(err, uids) {
var activeUsersEl = $('.thread_active_users'),
x;
if (uids && uids.length) { if (uids && uids.length) {
for(var x=0;x<uids.length;x++) { for(var x=0;x<uids.length;x++) {
activeUsersEl.find('[data-uid="' + uids[x] + '"]').addClass('replying'); activeEl.find('[data-uid="' + uids[x] + '"]').addClass('replying');
} }
} }
}); });

@ -166,15 +166,8 @@
module.flushdb = function(callback) { module.flushdb = function(callback) {
db.dropDatabase(function(err, result) { db.dropDatabase(function(err, result) {
if (err) {
winston.error(err.message);
if (typeof callback === 'function') {
return callback(err);
}
}
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(); callback(err);
} }
}); });
}; };
@ -551,8 +544,8 @@
value = value.toString(); value = value.toString();
} }
var data = { var data = {
score:score, score: parseInt(score, 10),
value:value value: value
}; };
db.collection('objects').update({_key:key, value:value}, {$set:data}, {upsert:true, w: 1}, function(err, result) { db.collection('objects').update({_key:key, value:value}, {$set:data}, {upsert:true, w: 1}, function(err, result) {

@ -117,11 +117,9 @@
module.flushdb = function(callback) { module.flushdb = function(callback) {
redisClient.send_command('flushdb', [], function(err) { redisClient.send_command('flushdb', [], function(err) {
if (err) { if (typeof callback === 'function') {
winston.error(err.message); callback(err);
return callback(err);
} }
callback();
}); });
}; };

@ -87,6 +87,9 @@ var fs = require('fs'),
Meta.themes = { Meta.themes = {
get: function (callback) { get: function (callback) {
var themePath = nconf.get('themes_path'); var themePath = nconf.get('themes_path');
if (typeof themePath !== 'string') {
return callback(null, []);
}
fs.readdir(themePath, function (err, files) { fs.readdir(themePath, function (err, files) {
async.filter(files, function (file, next) { async.filter(files, function (file, next) {
fs.stat(path.join(themePath, file), function (err, fileStat) { fs.stat(path.join(themePath, file), function (err, fileStat) {

@ -1,31 +1,39 @@
var winston = require('winston'); 'use strict';
process.on('uncaughtException', function (err) {
winston.error('Encountered error while running test suite: ' + err.message);
});
var assert = require('assert'), var assert = require('assert'),
db = require('../mocks/databasemock'); db = require('../mocks/databasemock'),
topics = require('../src/topics'),
categories = require('../src/categories');
var Topics = require('../src/topics');
describe('Topic\'s', function() { describe('Topic\'s', function() {
var topic; var topic,
categoryObj;
beforeEach(function(){
topic = { before(function(done) {
userId: 1,
categoryId: 1, categories.create({
title: 'Test Topic Title', name: 'Test Category',
content: 'The content of test topic' description: 'Test category created by testing script',
}; icon: 'fa-check',
blockclass: 'category-blue',
order: '5'
}, function(err, category) {
categoryObj = category;
topic = {
userId: 1,
categoryId: categoryObj.cid,
title: 'Test Topic Title',
content: 'The content of test topic'
};
done();
});
}); });
describe('.post', function() { describe('.post', function() {
it('should create a new topic with proper parameters', function(done) { it('should create a new topic with proper parameters', function(done) {
Topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function(err, result) { topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function(err, result) {
assert.equal(err, null, 'was created with error'); assert.equal(err, null, 'was created with error');
assert.ok(result); assert.ok(result);
@ -34,9 +42,7 @@ describe('Topic\'s', function() {
}); });
it('should fail to create new topic with wrong parameters', function(done) { it('should fail to create new topic with wrong parameters', function(done) {
topic.userId = null; topics.post({uid: null, title: topic.title, content: topic.content, cid: topic.categoryId}, function(err, result) {
Topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function(err, result) {
assert.equal(err.message, 'invalid-user'); assert.equal(err.message, 'invalid-user');
done(); done();
}); });
@ -47,8 +53,8 @@ describe('Topic\'s', function() {
var newTopic; var newTopic;
var newPost; var newPost;
beforeEach(function(done){ beforeEach(function(done) {
Topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function(err, result) { topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function(err, result) {
newTopic = result.topicData; newTopic = result.topicData;
newPost = result.postData; newPost = result.postData;
done(); done();
@ -57,13 +63,13 @@ describe('Topic\'s', function() {
describe('.getTopicData', function() { describe('.getTopicData', function() {
it('should not receive errors', function(done) { it('should not receive errors', function(done) {
Topics.getTopicData(newTopic.tid, done); topics.getTopicData(newTopic.tid, done);
}); });
}); });
describe('.getTopicDataWithUser', function() { describe('.getTopicDataWithUser', function() {
it('should not receive errors', function(done) { it('should not receive errors', function(done) {
Topics.getTopicDataWithUser(newTopic.tid, done); topics.getTopicDataWithUser(newTopic.tid, done);
}); });
}); });
}); });

@ -16,7 +16,7 @@ describe('User', function() {
beforeEach(function(){ beforeEach(function(){
userData = { userData = {
name: 'John Smith', username: 'John Smith',
password: 'swordfish', password: 'swordfish',
email: 'john@example.com', email: 'john@example.com',
callback: undefined callback: undefined
@ -25,8 +25,8 @@ describe('User', function() {
describe('when created', function() { describe('when created', function() {
it('should be created properly', function(done){ it('should be created properly', function(done) {
User.create({usename: userData.name, password: userData.password, email: userData.email}, function(error,userId){ User.create({username: userData.username, password: userData.password, email: userData.email}, function(error,userId){
assert.equal(error, null, 'was created with error'); assert.equal(error, null, 'was created with error');
assert.ok(userId); assert.ok(userId);
done(); done();
@ -35,7 +35,7 @@ describe('User', function() {
it('should have a valid email, if using an email', function() { it('should have a valid email, if using an email', function() {
assert.throws( assert.throws(
User.create({username: userData.name, password: userData.password, email: 'fakeMail'},function(){}), User.create({username: userData.username, password: userData.password, email: 'fakeMail'},function(){}),
Error, Error,
'does not validate email' 'does not validate email'
); );

Loading…
Cancel
Save