|
@@ -19,6 +19,8 @@ describe "UserRegistrationHandler", ->
|
|
|
@UserCreator =
|
|
@UserCreator =
|
|
|
createNewUser:sinon.stub().callsArgWith(1, null, @user)
|
|
createNewUser:sinon.stub().callsArgWith(1, null, @user)
|
|
|
@AuthenticationManager =
|
|
@AuthenticationManager =
|
|
|
|
|
+ validateEmail: sinon.stub().returns(null)
|
|
|
|
|
+ validatePassword: sinon.stub().returns(null)
|
|
|
setUserPassword: sinon.stub().callsArgWith(2)
|
|
setUserPassword: sinon.stub().callsArgWith(2)
|
|
|
@NewsLetterManager =
|
|
@NewsLetterManager =
|
|
|
subscribe: sinon.stub().callsArgWith(1)
|
|
subscribe: sinon.stub().callsArgWith(1)
|
|
@@ -44,28 +46,25 @@ describe "UserRegistrationHandler", ->
|
|
|
|
|
|
|
|
|
|
|
|
|
describe 'validate Register Request', ->
|
|
describe 'validate Register Request', ->
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- it 'allow working account through', ->
|
|
|
|
|
|
|
+ it 'allows passing validation through', ->
|
|
|
result = @handler._registrationRequestIsValid @passingRequest
|
|
result = @handler._registrationRequestIsValid @passingRequest
|
|
|
result.should.equal true
|
|
result.should.equal true
|
|
|
-
|
|
|
|
|
- it 'not allow not valid email through ', ()->
|
|
|
|
|
- @passingRequest.email = "notemail"
|
|
|
|
|
- result = @handler._registrationRequestIsValid @passingRequest
|
|
|
|
|
- result.should.equal false
|
|
|
|
|
|
|
|
|
|
- it 'not allow no email through ', ->
|
|
|
|
|
- @passingRequest.email = ""
|
|
|
|
|
- result = @handler._registrationRequestIsValid @passingRequest
|
|
|
|
|
- result.should.equal false
|
|
|
|
|
-
|
|
|
|
|
- it 'not allow no password through ', ()->
|
|
|
|
|
- @passingRequest.password= ""
|
|
|
|
|
- result = @handler._registrationRequestIsValid @passingRequest
|
|
|
|
|
- result.should.equal false
|
|
|
|
|
|
|
+ describe 'failing email validation', ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @AuthenticationManager.validateEmail.returns({ message: 'email not set' })
|
|
|
|
|
|
|
|
|
|
+ it 'does not allow through', ->
|
|
|
|
|
+ result = @handler._registrationRequestIsValid @passingRequest
|
|
|
|
|
+ result.should.equal false
|
|
|
|
|
+
|
|
|
|
|
+ describe 'failing password validation', ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @AuthenticationManager.validatePassword.returns({ message: 'password is too short' })
|
|
|
|
|
|
|
|
|
|
+ it 'does not allow through', ->
|
|
|
|
|
+ result = @handler._registrationRequestIsValid @passingRequest
|
|
|
|
|
+ result.should.equal false
|
|
|
|
|
|
|
|
describe "registerNewUser", ->
|
|
describe "registerNewUser", ->
|
|
|
|
|
|