This commit is contained in:
barisusakli
2016-11-24 11:02:53 +03:00
parent d3fff28de5
commit 4b815449f1
3 changed files with 28 additions and 2 deletions

View File

@@ -63,7 +63,7 @@ editController.email = function (req, res, next) {
function renderRoute(name, req, res, next) {
getUserData(req, next, function (err, userData) {
if (err) {
if (err || !userData) {
return next(err);
}
if ((name === 'username' && userData['username:disableEdit']) || (name === 'email' && userData['email:disableEdit'])) {
@@ -94,7 +94,7 @@ function getUserData(req, next, callback) {
function (data, next) {
userData = data;
if (!userData) {
return next();
return callback();
}
db.getObjectField('user:' + userData.uid, 'password', next);
}

View File

@@ -126,6 +126,14 @@ describe('Admin Controllers', function () {
});
});
it('should 404 for edit/email page if user does not exist', function (done) {
request(nconf.get('url') + '/api/user/doesnotexist/edit/email', {jar: jar, json: true}, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
});
});
it('should load /admin/general/homepage', function (done) {
request(nconf.get('url') + '/api/admin/general/homepage', {jar: jar, json: true}, function (err, res, body) {
assert.ifError(err);

View File

@@ -524,6 +524,24 @@ describe('User', function () {
});
});
it('should load edit page', function (done) {
request(nconf.get('url') + '/api/user/updatedagain/edit', {jar: jar, json: true}, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
done();
});
});
it('should load edit/email page', function (done) {
request(nconf.get('url') + '/api/user/updatedagain/edit/email', {jar: jar, json: true}, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
done();
});
});
it('should load user\'s groups page', function (done) {
groups.create({
name: 'Test',