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 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;

@ -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);

Loading…
Cancel
Save