Fix #1292 - unexpected results when passing undefined to Model.hasChanged()

* additional check in hashChanged for when `attr` is present but undefined
* adds tests for expected results when passing undefined
This commit is contained in:
Sam Breed
2012-05-07 19:45:03 -06:00
parent 36dfdab567
commit cacd01d530
2 changed files with 5 additions and 1 deletions

View File

@@ -279,11 +279,15 @@ $(document).ready(function() {
equal(model.previous('name'), 'Tim');
ok(_.isEqual(model.previousAttributes(), {name : "Tim", age : 10}), 'previousAttributes is correct');
});
equal(model.hasChanged(), false);
equal(model.hasChanged(undefined), false);
model.set({name : 'Rob'}, {silent : true});
equal(model.hasChanged(), true);
equal(model.hasChanged(undefined), true);
equal(model.hasChanged('name'), true);
model.change();
equal(model.get('name'), 'Rob');
});
test("Model: changedAttributes", function() {