Ensure we lowercase all emails

This ensures the uniqueness of that field
This commit is contained in:
Johannes Zellner
2016-04-05 11:15:47 +02:00
parent 544c1474d1
commit 94faa3575c
2 changed files with 29 additions and 6 deletions

View File

@@ -69,6 +69,18 @@ describe('database', function () {
displayName: 'Herbert Heidelberg'
};
var USER_3 = {
id: 'uuid458',
username: '',
password: 'secret',
email: 'SAFE3@me.com',
salt: 'tata',
createdAt: 'sometime back',
modifiedAt: 'now',
resetToken: '',
displayName: 'Herbert Heidelberg'
};
it('can add user', function (done) {
userdb.add(USER_0.id, USER_0, done);
});
@@ -89,6 +101,14 @@ describe('database', function () {
});
});
it('cannot add user with same but uppercase email again', function (done) {
userdb.add(USER_3.id, USER_3, function (error) {
expect(error).to.be.ok();
expect(error.reason).to.be(DatabaseError.ALREADY_EXISTS);
done();
});
});
it('can get by user id', function (done) {
userdb.get(USER_0.id, function (error, user) {
expect(error).to.not.be.ok();
@@ -180,11 +200,10 @@ describe('database', function () {
});
});
it('cannot update with null field', function (done) {
userdb.update(USER_0.id, { email: null }, function (error) {
expect(error).to.be.ok();
done();
});
it('cannot update with null field', function () {
expect(function () {
userdb.update(USER_0.id, { email: null }, function () {});
}).to.throwError();
});
it('cannot del non-existing user', function (done) {