Skip to content

Commit

Permalink
Merge branch 'patch-1' of git://github.com/akshaddhoke/backbone.valid…
Browse files Browse the repository at this point in the history
…ation into akshaddhoke-patch-1
  • Loading branch information
chiefGui committed May 8, 2015
2 parents 05078b7 + 0a3fb49 commit 1b949ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/backbone-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ Backbone.Validation = (function(_){
// Removes view from associated views of the model or the methods
// added to a model if no view or single view provided
var unbindModel = function(model, view) {
if (view && model.associatedViews.length > 1){
if (view && model.associatedViews && model.associatedViews.length > 1){
model.associatedViews = _.without(model.associatedViews, view);
} else {
delete model.validate;
Expand Down
7 changes: 7 additions & 0 deletions tests/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ buster.testCase("Backbone.Validation", {
}
},

"when unbinding view which was not bound": {
"nothing happens": function(){
Backbone.Validation.unbind(new Backbone.View({model:new Backbone.Model()}));
assert(true);
}
},

"when bound to model with two validated attributes": {
setUp: function() {
Backbone.Validation.bind(this.view);
Expand Down

0 comments on commit 1b949ca

Please sign in to comment.