removing obsolete error case.

This commit is contained in:
Jeremy Ashkenas
2012-02-02 17:15:28 -05:00
parent 7c10181c64
commit a865aa41f1
2 changed files with 1 additions and 31 deletions

View File

@@ -173,9 +173,7 @@
this.attributes = {};
this._escapedAttributes = {};
this.cid = _.uniqueId('c');
if (!this.set(attributes, {silent: true})) {
throw new Error("Can't create an invalid model");
}
this.set(attributes, {silent: true});
delete this._changed;
this._previousAttributes = _.clone(this.attributes);
this.initialize.apply(this, arguments);

View File

@@ -59,34 +59,6 @@ $(document).ready(function() {
equal(col.get(101), model);
});
test("Collection: add model with attributes modified by set", function() {
var CustomSetModel = Backbone.Model.extend({
defaults: {
number_as_string: null //presence of defaults forces extend
},
validate: function (attributes) {
if (!_.isString(attributes.num_as_string)) {
return 'fail';
}
},
set: function (attributes, options) {
if (attributes.num_as_string) {
attributes.num_as_string = attributes.num_as_string.toString();
}
Backbone.Model.prototype.set.call(this, attributes, options);
}
});
var CustomSetCollection = Backbone.Collection.extend({
model: CustomSetModel
});
raises(function(){
new CustomSetCollection([{ num_as_string: 2 }]);
});
});
test("Collection: update index when id changes", function() {
var col = new Backbone.Collection();
col.add([