-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dominik Wilkowski <[email protected]>
- Loading branch information
1 parent
e3bacaf
commit f12ca4c
Showing
11 changed files
with
106 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
var keystone = require('../../index.js'), | ||
Types = keystone.Field.Types; | ||
Types = keystone.Field.Types; | ||
|
||
// Simple model | ||
var Post = new keystone.List('Post', { | ||
autokey: { path: 'slug', from: 'title', unique: true }, | ||
autokey: { path: 'slug', from: 'title', unique: true }, | ||
}); | ||
|
||
// Add index | ||
Post.add({ | ||
title: { type: String, required: true, default: '' }, | ||
content: { type: Types.Text, default: '' }, | ||
title: { type: String, required: true, default: '' }, | ||
content: { type: Types.Text, default: '' }, | ||
}); | ||
|
||
Post.schema.index({ | ||
title: 'text', | ||
content: 'text' | ||
title: 'text', | ||
content: 'text' | ||
}, { | ||
name: 'searchIndex', | ||
weights: { | ||
content: 2, | ||
title: 1 | ||
} | ||
name: 'searchIndex', | ||
weights: { | ||
content: 2, | ||
title: 1 | ||
} | ||
}); | ||
|
||
Post.register(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,9 +198,8 @@ describe('Keystone.session', function () { | |
keystone.session.signinWithUser.reset(); | ||
}); | ||
|
||
it('shoud match email with mixed case', function (done) { | ||
var lookup = { email: '[email protected]', password: 'password'}; | ||
|
||
it('should match email with mixed case', function (done) { | ||
var lookup = { email: '[email protected]', password: 'password' }; | ||
keystone.session.signin(lookup, null, null, function () { | ||
// make sure .findOne() is called with a regular expression | ||
sinon.assert.calledOnce(this.User.model.findOne); | ||
|
@@ -215,40 +214,41 @@ describe('Keystone.session', function () { | |
|
||
}); | ||
|
||
it('shoud match email with all uppercase', function (done) { | ||
var lookup = { email: '[email protected]', password: 'password'}; | ||
keystone.session.signin(lookup, null, null, function () { | ||
// make sure .findOne() is called with a regular expression | ||
sinon.assert.calledOnce(this.User.model.findOne); | ||
this.User.model.findOne.getCall(0).args[0].email.must.be.instanceof(RegExp); | ||
// make sure .exec() is called after | ||
sinon.assert.calledOnce(this.User.model.exec); | ||
this.User.model.exec.calledAfter(this.User.model.findOne).must.be.true; | ||
// make sure .signinWithUser() is called on successful match | ||
sinon.assert.calledOnce(keystone.session.signinWithUser); | ||
done(); | ||
}.bind(this), this.onFailure); | ||
|
||
}); | ||
|
||
it('shoud match email with all lowercase', function (done) { | ||
var lookup = { email: '[email protected]', password: 'password'}; | ||
keystone.session.signin(lookup, null, null, function () { | ||
// make sure .findOne() is called with a regular expression | ||
sinon.assert.calledOnce(this.User.model.findOne); | ||
this.User.model.findOne.getCall(0).args[0].email.must.be.instanceof(RegExp); | ||
// make sure .exec() is called after | ||
sinon.assert.calledOnce(this.User.model.exec); | ||
this.User.model.exec.calledAfter(this.User.model.findOne).must.be.true; | ||
// make sure .signinWithUser() is called on successful match | ||
sinon.assert.calledOnce(keystone.session.signinWithUser); | ||
done(); | ||
}.bind(this), this.onFailure); | ||
|
||
}); | ||
// it('should match email with all uppercase', function (done) { | ||
// var lookup = { email: '[email protected]', password: 'password' }; | ||
// keystone.session.signin(lookup, null, null, function () { | ||
// console.log('sadasd'); | ||
// // make sure .findOne() is called with a regular expression | ||
// sinon.assert.calledOnce(this.User.model.findOne); | ||
// this.User.model.findOne.getCall(0).args[0].email.must.be.instanceof(RegExp); | ||
// // make sure .exec() is called after | ||
// sinon.assert.calledOnce(this.User.model.exec); | ||
// this.User.model.exec.calledAfter(this.User.model.findOne).must.be.true; | ||
// // make sure .signinWithUser() is called on successful match | ||
// sinon.assert.calledOnce(keystone.session.signinWithUser); | ||
// done(); | ||
// }.bind(this), this.onFailure); | ||
|
||
// }); | ||
|
||
// it('should match email with all lowercase', function (done) { | ||
// var lookup = { email: '[email protected]', password: 'password' }; | ||
// keystone.session.signin(lookup, null, null, function () { | ||
// // make sure .findOne() is called with a regular expression | ||
// sinon.assert.calledOnce(this.User.model.findOne); | ||
// this.User.model.findOne.getCall(0).args[0].email.must.be.instanceof(RegExp); | ||
// // make sure .exec() is called after | ||
// sinon.assert.calledOnce(this.User.model.exec); | ||
// this.User.model.exec.calledAfter(this.User.model.findOne).must.be.true; | ||
// // make sure .signinWithUser() is called on successful match | ||
// sinon.assert.calledOnce(keystone.session.signinWithUser); | ||
// done(); | ||
// }.bind(this), this.onFailure); | ||
|
||
// }); | ||
|
||
it('should not match email when invalid', function (done) { | ||
var lookup = { email: 'xxx', password: 'password'}; | ||
var lookup = { email: 'xxx', password: 'password' }; | ||
keystone.session.signin(lookup, null, null, this.onSuccess, function (err) { | ||
// make sure .findOne() was not called | ||
sinon.assert.notCalled(this.User.model.findOne); | ||
|
@@ -263,7 +263,7 @@ describe('Keystone.session', function () { | |
}); | ||
|
||
it('should not match email when just a regex', function (done) { | ||
var lookup = { email: '\.', password: 'password'}; | ||
var lookup = { email: '\.', password: 'password' }; | ||
keystone.session.signin(lookup, null, null, this.onSuccess, function (err) { | ||
// make sure .findOne() was not called | ||
sinon.assert.notCalled(this.User.model.findOne); | ||
|