Skip to content

Commit

Permalink
Merge pull request canjs#65 from yusufsafak/master
Browse files Browse the repository at this point in the history
bugfix Model, Model store and test.  I need to update the formatting.
  • Loading branch information
justinbmeyer committed Sep 26, 2011
2 parents a6a16e7 + 10b3b4a commit 0ee997d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
13 changes: 7 additions & 6 deletions model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,11 +698,12 @@ steal('jquery/class', 'jquery/lang/string', function() {
}
})

//add missing converters
if ( superClass.convert != this.convert ) {
this.convert = extend(superClass.convert, this.convert);
}

//add missing converters and serializes
each(["convert","serialize"],function(i,name){
if (superClass[name] != self[name] ) {
self[name] =extend(superClass[name], self[name]);
}
});

this._fullName = underscore(this.fullName.replace(/\./g, "_"));
this._shortName = underscore(this.shortName);
Expand Down Expand Up @@ -1848,4 +1849,4 @@ steal('jquery/class', 'jquery/lang/string', function() {
* - <code>deferred</code> - A deferred that gets resolved to any additional attrs
* that might need to be set on the model instance.
*/
});
});
9 changes: 5 additions & 4 deletions model/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ $.Class('jQuery.Model.Store',
}*/
},
// this is mostly unnecessary
remove : function(id){
if(id.id !== undefined){
id = id.id;
remove : function(ev,id){
var idProp = this.id;
if(id[idProp] !== undefined){
id = id[idProp];
}
var item = this.data[id];
if(!item){
Expand Down Expand Up @@ -389,4 +390,4 @@ $.Class('jQuery.Model.Store',
},{});


});
});
2 changes: 2 additions & 0 deletions model/store/store_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ test("Store Remove", function(){
list.bind("remove", function(ev, items){
ok(items[0] === first, "removed first item");
equals(list.length, len - 1, "length adjusted")
var list2 = Item.Store.findAll({parentId: 1});
ok(list2.get(first.id)[0] === undefined, "Model Store remove callback");
start();
})
});
Expand Down
7 changes: 6 additions & 1 deletion model/test/qunit/model_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,13 @@ test("serialize", function(){
var d = new Date();
d.setMonth(1)
equals(new Task({
createdAt: d
createdAt: d,
name:"Task1"
}).serialize().createdAt, "feb", "serialized")
equals(new Task({
createdAt: d,
name:"Task2"
}).serialize().name, "Task2", "default serialized")
});

test("removeAttr test", function(){
Expand Down

0 comments on commit 0ee997d

Please sign in to comment.