Merge branch 'master' of github.com:spmason/backbone

This commit is contained in:
Irene Ros
2011-10-29 11:39:35 -04:00
2 changed files with 14 additions and 0 deletions

View File

@@ -374,6 +374,12 @@
changed[attr] = now[attr];
}
}
for (attr in old){
if (!(attr in now)){
changed = changed || {};
changed[attr] = void 0;
}
}
return changed;
},

View File

@@ -170,6 +170,14 @@ $(document).ready(function() {
equals(i, 2, 'Unset does not fire an event for missing attributes.');
});
test("Model: unset and changedAttributes", function() {
var model = new Backbone.Model({a: 1});
model.unset('a', {silent: true});
var changedAttributes = model.changedAttributes();
ok('a' in changedAttributes, 'changedAttributes should contain unset properties');
equals(changedAttributes.a, undefined);
});
test("Model: using a non-default id attribute.", function() {
var MongoModel = Backbone.Model.extend({idAttribute : '_id'});
var model = new MongoModel({id: 'eye-dee', _id: 25, title: 'Model'});