Ensure we lowercase all emails
This ensures the uniqueness of that field
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user