Skip to content
This repository

bugfix Model, Model store and test #65

Merged
merged 2 commits into from almost 3 years ago

2 participants

yusufsafak Justin Meyer
yusufsafak

Hi,
Sorry, I am newbie to github. I fix some bugs and create some test as I mentioned in forum http://forum.javascriptmvc.com/#Topic/32525000000656013 I also newbie to qunit so my tests may not be good.

Thanks,
Safak

Justin Meyer justinbmeyer commented on the diff
model/model.js
@@ -698,11 +698,12 @@ steal('jquery/class', 'jquery/lang/string', function() {
698 698 }
699 699 })
700 700
701   - //add missing converters
702   - if ( superClass.convert != this.convert ) {
703   - this.convert = extend(superClass.convert, this.convert);
704   - }
705   -
  701 + //add missing converters and serializes
1
Justin Meyer Owner

The formatting is messed up here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Justin Meyer justinbmeyer merged commit 8510326 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Sep 21, 2011
yusufsafak yusufsafak bugfix Model and Model.Store a938e3a
yusufsafak yusufsafak bugfix Model 0311066
This page is out of date. Refresh to see the latest.
13 model/model.js
@@ -698,11 +698,12 @@ steal('jquery/class', 'jquery/lang/string', function() {
698 698 }
699 699 })
700 700
701   - //add missing converters
702   - if ( superClass.convert != this.convert ) {
703   - this.convert = extend(superClass.convert, this.convert);
704   - }
705   -
  701 + //add missing converters and serializes
  702 + each(["convert","serialize"],function(i,name){
  703 + if (superClass[name] != self[name] ) {
  704 + self[name] =extend(superClass[name], self[name]);
  705 + }
  706 + });
706 707
707 708 this._fullName = underscore(this.fullName.replace(/\./g, "_"));
708 709 this._shortName = underscore(this.shortName);
@@ -1848,4 +1849,4 @@ steal('jquery/class', 'jquery/lang/string', function() {
1848 1849 * - <code>deferred</code> - A deferred that gets resolved to any additional attrs
1849 1850 * that might need to be set on the model instance.
1850 1851 */
1851   -});
  1852 +});
9 model/store/store.js
@@ -44,9 +44,10 @@ $.Class('jQuery.Model.Store',
44 44 }*/
45 45 },
46 46 // this is mostly unnecessary
47   - remove : function(id){
48   - if(id.id !== undefined){
49   - id = id.id;
  47 + remove : function(ev,id){
  48 + var idProp = this.id;
  49 + if(id[idProp] !== undefined){
  50 + id = id[idProp];
50 51 }
51 52 var item = this.data[id];
52 53 if(!item){
@@ -389,4 +390,4 @@ $.Class('jQuery.Model.Store',
389 390 },{});
390 391
391 392
392   -});
  393 +});
2  model/store/store_test.js
@@ -135,6 +135,8 @@ test("Store Remove", function(){
135 135 list.bind("remove", function(ev, items){
136 136 ok(items[0] === first, "removed first item");
137 137 equals(list.length, len - 1, "length adjusted")
  138 + var list2 = Item.Store.findAll({parentId: 1});
  139 + ok(list2.get(first.id)[0] === undefined, "Model Store remove callback");
138 140 start();
139 141 })
140 142 });
7 model/test/qunit/model_test.js
@@ -401,8 +401,13 @@ test("serialize", function(){
401 401 var d = new Date();
402 402 d.setMonth(1)
403 403 equals(new Task({
404   - createdAt: d
  404 + createdAt: d,
  405 + name:"Task1"
405 406 }).serialize().createdAt, "feb", "serialized")
  407 + equals(new Task({
  408 + createdAt: d,
  409 + name:"Task2"
  410 + }).serialize().name, "Task2", "default serialized")
406 411 });
407 412
408 413 test("removeAttr test", function(){

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.