diff --git a/src/controllers/accounts/categories.js b/src/controllers/accounts/categories.js index ee153a00b7..a97f770373 100644 --- a/src/controllers/accounts/categories.js +++ b/src/controllers/accounts/categories.js @@ -6,8 +6,7 @@ var user = require('../../user'); var categories = require('../../categories'); var accountHelpers = require('./helpers'); -var categoriesController = {}; - +var categoriesController = module.exports; categoriesController.get = function (req, res, callback) { var userData; @@ -30,19 +29,14 @@ categoriesController.get = function (req, res, callback) { }, }, next); }, - function (results, next) { + function (results) { flattenArray(results); userData.categories = results.all; - next(); - }, - ], function (err) { - if (err) { - return callback(err); - } - userData.title = '[[pages:account/watched_categories]]'; - res.render('account/categories', userData); - }); + userData.title = '[[pages:account/watched_categories]]'; + res.render('account/categories', userData); + }, + ], callback); }; function moveChildrenToRoot(child) { @@ -66,5 +60,3 @@ function flattenArray(results) { } } } - -module.exports = categoriesController; diff --git a/test/controllers.js b/test/controllers.js index 44259db3b7..e26694ba4d 100644 --- a/test/controllers.js +++ b/test/controllers.js @@ -1182,6 +1182,15 @@ describe('Controllers', function () { }); }); + it('should load /user/foo/categories', function (done) { + request(nconf.get('url') + '/api/user/foo/categories', { jar: jar }, function (err, res, body) { + assert.ifError(err); + assert.equal(res.statusCode, 200); + assert(body); + done(); + }); + }); + it('should load /user/foo/uploads', function (done) { request(nconf.get('url') + '/api/user/foo/uploads', { jar: jar }, function (err, res, body) { assert.ifError(err);