mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
add test for composer fix
This commit is contained in:
@@ -8,15 +8,15 @@ var plugins = require('../plugins');
|
|||||||
var topics = require('../topics');
|
var topics = require('../topics');
|
||||||
var helpers = require('./helpers');
|
var helpers = require('./helpers');
|
||||||
|
|
||||||
exports.get = function (req, res, next) {
|
exports.get = function (req, res, callback) {
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (_next) {
|
function (next) {
|
||||||
plugins.fireHook('filter:composer.build', {
|
plugins.fireHook('filter:composer.build', {
|
||||||
req: req,
|
req: req,
|
||||||
res: res,
|
res: res,
|
||||||
next: next,
|
next: callback,
|
||||||
templateData: {},
|
templateData: {},
|
||||||
}, _next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (data) {
|
function (data) {
|
||||||
if (data.templateData.disabled) {
|
if (data.templateData.disabled) {
|
||||||
@@ -28,7 +28,7 @@ exports.get = function (req, res, next) {
|
|||||||
res.render('compose', data.templateData);
|
res.render('compose', data.templateData);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
], next);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.post = function (req, res) {
|
exports.post = function (req, res) {
|
||||||
|
|||||||
@@ -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) {
|
it('should error with invalid data', function (done) {
|
||||||
request.post(nconf.get('url') + '/compose', {
|
request.post(nconf.get('url') + '/compose', {
|
||||||
form: {
|
form: {
|
||||||
|
|||||||
Reference in New Issue
Block a user