Skip to content

Node.js based forum software built for the modern web

add test for composer fix

Barış Soner Uşaklıd96674da6430
diff --git a/src/controllers/composer.js b/src/controllers/composer.js
index 3bc95fae4a..7bd61a5bb2 100644
--- a/src/controllers/composer.js
+++ b/src/controllers/composer.js
@@ -8,15 +8,15 @@ var plugins = require('../plugins');
var topics = require('../topics');
var helpers = require('./helpers');
-exports.get = function (req, res, next) {
+exports.get = function (req, res, callback) {
async.waterfall([
- function (_next) {
+ function (next) {
plugins.fireHook('filter:composer.build', {
req: req,
res: res,
- next: next,
+ next: callback,
templateData: {},
- }, _next);
+ }, next);
},
function (data) {
if (data.templateData.disabled) {
@@ -28,7 +28,7 @@ exports.get = function (req, res, next) {
res.render('compose', data.templateData);
}
},
- ], next);
+ ], callback);
};
exports.post = function (req, res) {
diff --git a/test/controllers.js b/test/controllers.js
index 213472d548..6293f60e2f 100644
--- a/test/controllers.js
+++ b/test/controllers.js
@@ -2036,6 +2036,27 @@ describe('Controllers', function () {
});
});
+ it('should 404 if plugin calls next', function (done) {
+ function hookMethod(hookData, callback) {
+ hookData.next();
+ }
+
+ plugins.registerHook('myTestPlugin', {
+ hook: 'filter:composer.build',
+ method: hookMethod,
+ });
+
+ request(nconf.get('url') + '/api/compose', { json: true }, function (err, res, body) {
+ assert.ifError(err);
+ assert.equal(res.statusCode, 404);
+ console.log(body);
+
+ plugins.unregisterHook('myTestPlugin', 'filter:composer.build', hookMethod);
+ done();
+ });
+ });
+
+
it('should error with invalid data', function (done) {
request.post(nconf.get('url') + '/compose', {
form: {