small changes and test for user/:slug/categories

v1.18.x
Baris Usakli 6 years ago
parent 523a2dc54c
commit 9ed4239d8e

@ -6,8 +6,7 @@ var user = require('../../user');
var categories = require('../../categories'); var categories = require('../../categories');
var accountHelpers = require('./helpers'); var accountHelpers = require('./helpers');
var categoriesController = {}; var categoriesController = module.exports;
categoriesController.get = function (req, res, callback) { categoriesController.get = function (req, res, callback) {
var userData; var userData;
@ -30,19 +29,14 @@ categoriesController.get = function (req, res, callback) {
}, },
}, next); }, next);
}, },
function (results, next) { function (results) {
flattenArray(results); flattenArray(results);
userData.categories = results.all; userData.categories = results.all;
next();
},
], function (err) {
if (err) {
return callback(err);
}
userData.title = '[[pages:account/watched_categories]]'; userData.title = '[[pages:account/watched_categories]]';
res.render('account/categories', userData); res.render('account/categories', userData);
}); },
], callback);
}; };
function moveChildrenToRoot(child) { function moveChildrenToRoot(child) {
@ -66,5 +60,3 @@ function flattenArray(results) {
} }
} }
} }
module.exports = categoriesController;

@ -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) { it('should load /user/foo/uploads', function (done) {
request(nconf.get('url') + '/api/user/foo/uploads', { jar: jar }, function (err, res, body) { request(nconf.get('url') + '/api/user/foo/uploads', { jar: jar }, function (err, res, body) {
assert.ifError(err); assert.ifError(err);

Loading…
Cancel
Save