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

v1.18.x
Julian Lam 12 years ago
commit 33150943df

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
clear clear
echo "Launching NodeBB in \"development\" mode." echo "Launching NodeBB in \"development\" mode."
echo "To run the production build of NodeBB, please use \"forever\"." echo "To run the production build of NodeBB, please use \"forever\"."

@ -1,31 +1,33 @@
var express = require('express'), var path = require('path'),
fs = require('fs'),
express = require('express'),
express_namespace = require('express-namespace'), express_namespace = require('express-namespace'),
WebServer = express(), WebServer = express(),
server = require('http').createServer(WebServer), server = require('http').createServer(WebServer),
RedisStore = require('connect-redis')(express), RedisStore = require('connect-redis')(express),
path = require('path'),
RDB = require('./redis'),
utils = require('../public/src/utils.js'),
pkg = require('../package.json'),
fs = require('fs'),
user = require('./user.js'),
categories = require('./categories.js'),
posts = require('./posts.js'),
topics = require('./topics.js'),
notifications = require('./notifications.js'),
admin = require('./routes/admin.js'),
userRoute = require('./routes/user.js'),
apiRoute = require('./routes/api.js'),
auth = require('./routes/authentication.js'),
meta = require('./meta.js'),
feed = require('./feed'),
plugins = require('./plugins'),
nconf = require('nconf'), nconf = require('nconf'),
winston = require('winston'), winston = require('winston'),
validator = require('validator'), validator = require('validator'),
async = require('async'), async = require('async'),
logger = require('./logger.js');
pkg = require('../package.json'),
utils = require('../public/src/utils'),
RDB = require('./redis'),
user = require('./user'),
categories = require('./categories'),
posts = require('./posts'),
topics = require('./topics'),
notifications = require('./notifications'),
admin = require('./routes/admin'),
userRoute = require('./routes/user'),
apiRoute = require('./routes/api'),
auth = require('./routes/authentication'),
meta = require('./meta'),
feed = require('./feed'),
plugins = require('./plugins'),
logger = require('./logger');
(function (app) { (function (app) {
"use strict"; "use strict";
@ -144,7 +146,7 @@ var express = require('express'),
res.locals.csrf_token = req.session._csrf; res.locals.csrf_token = req.session._csrf;
// Disable framing // Disable framing
res.setHeader("X-Frame-Options", "DENY"); res.setHeader('X-Frame-Options', 'DENY');
next(); next();
}); });
@ -645,7 +647,7 @@ var express = require('express'),
req: req, req: req,
res: res res: res
}, function (err, header) { }, function (err, header) {
res.send(header + app.create_route("recent/" + req.params.term, null, "recent") + templates.footer); res.send(header + app.create_route('recent/' + req.params.term, null, 'recent') + templates.footer);
}); });
}); });
@ -676,7 +678,7 @@ var express = require('express'),
req: req, req: req,
res: res res: res
}, function (err, header) { }, function (err, header) {
res.send(header + app.create_route("search/" + req.params.term, null, "search") + templates.footer); res.send(header + app.create_route('search/' + req.params.term, null, 'search') + templates.footer);
}); });
}); });

@ -1,6 +1,3 @@
var winston = require('winston'); var winston = require('winston');
process.on('uncaughtException', function (err) { process.on('uncaughtException', function (err) {
@ -19,61 +16,64 @@ reds.createClient = function () {
var Topics = require('../src/topics'); var Topics = require('../src/topics');
describe('Topics', function() { describe('Topic\'s', function() {
var newTopic; var topic;
var newPost;
var userInfo; beforeEach(function(){
topic = {
userId: 1,
categoryId: 1,
title: 'Test Topic Title',
content: 'The content of test topic'
};
});
describe('.post', function() { describe('.post', function() {
it('should post a new topic', function(done) {
var uid = 1,
cid = 1,
title = 'Test Topic Title',
content = 'The content of test topic';
Topics.post(uid, title, content, cid, function(err, result) { it('should create a new topic with proper parameters', function(done) {
Topics.post(topic.userId, topic.title, topic.content, 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);
newTopic = result.topicData;
newPost = result.postData;
done(); done();
}); });
}); });
it('should fail posting a topic', function(done) { it('should fail to create new topic with wrong parameters', function(done) {
var uid = null, topic.userId = null;
cid = 1,
title = 'Test Topic Title',
content = 'The content of test topic';
Topics.post(uid, title, content, cid, function(err, result) { Topics.post(topic.userId, topic.title, topic.content, topic.categoryId, function(err, result) {
assert.equal(err.message, 'not-logged-in'); assert.equal(err.message, 'not-logged-in');
done(); done();
}); });
}); });
}); });
describe('.getTopicData', function() { describe('Get methods', function() {
it('should get Topic data', function(done) { var newTopic;
Topics.getTopicData(newTopic.tid, function(err, result) { var newPost;
done.apply(this.arguments);
}); beforeEach(function(done){
Topics.post(topic.userId, topic.title, topic.content, topic.categoryId, function(err, result) {
newTopic = result.topicData;
newPost = result.postData;
done();
}); });
}); });
describe('.getTopicData', function() {
it('should not receive errors', function(done) {
Topics.getTopicData(newTopic.tid, done);
});
});
describe('.getTopicDataWithUser', function() { describe('.getTopicDataWithUser', function() {
it('should get Topic data with user info', function(done) { it('should not receive errors', function(done) {
Topics.getTopicDataWithUser(newTopic.tid, function(err, result) { Topics.getTopicDataWithUser(newTopic.tid, done);
done.apply(this.arguments);
}); });
}); });
}); });
after(function() { after(function() {
RDB.send_command('flushdb', [], function(error){ RDB.send_command('flushdb', [], function(error){
if(error){ if(error){

Loading…
Cancel
Save