Skip to content

Commit

Permalink
Fix tests to detect #76
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Ng committed Jul 15, 2013
1 parent ad4d7c6 commit 9034baa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/fixtures/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var User = function () {
this.validatesPresent('login');
this.validatesFormat('login', /[a-z]+/, {message: 'Subdivisions!'});
this.validatesLength('login', {min: 3, on: ['create', 'reify']});
this.validatesConfirmed('password', 'confirmPassword', {on: 'create'});
this.validatesConfirmed('password', 'confirmPassword', {on: 'create', message: 'Parallax!'});

this.hasOne('Profile');
this.hasMany('Accounts');
Expand Down
15 changes: 12 additions & 3 deletions test/unit/create_user.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,20 @@ tests = {
_params.login = '2112'; // Contains numbers, invalid
var user = User.create(_params);
// Error message should be customized
assert.ok(user.errors.login, 'Subdivisions!');
assert.equal(user.errors.login, 'Subdivisions!');
}

, 'test invalid password with custom error message': function () {
_params.login = 'zzzz';
_params.password = 'bbbb'; // Wrong
var user = User.create(_params);
// Error message should be customized
assert.equal(user.errors.password, 'Parallax!');
}

, 'test login is not too short when updating': function () {
_params.login = 'zzzzz'; // Long enough to create
_params.password = 'asdf';
var user = User.create(_params);
assert.ok(!user.errors);
_params.login = 'zz'; // Too short, but should be valid on updates
Expand All @@ -55,9 +64,9 @@ tests = {
_params.login = 'zzzzzz';
var user = User.create(_params, {scenario: 'update'});
assert.ok(user.errors == null);

_params.login = 'zz'; // Usually valid on updates, we're going to make it invalid by passing scenario:create

user.updateProperties(_params, {scenario: 'create'});
assert.ok(typeof user.errors.login != 'undefined');
}
Expand Down

0 comments on commit 9034baa

Please sign in to comment.