jupiterjs / jquerymx

jQuery MVC Extensions. jQuery extensions that makes all the annoying stuff easier.
http://javascriptmvc.com
553 stars 374 forks source link

$.fixture.make always filters out any fixtures when 'parentId'-like param is present #132

Open LazyDev2k opened 12 years ago

LazyDev2k commented 12 years ago

Fixture function created by $.fixture.make filters out any fixtures when request parameter contain "Id" or "_id" string and there is no way to turn this off.

Code from dom/fixture/fixture.js:

if ( settings.data[param] !== undefined && // don't do this if the value of the param is null (ignore it)
    (param.indexOf("Id") != -1 || param.indexOf("_id") != -1) ) {
    while ( i < retArr.length ) {
        if ( settings.data[param] != retArr[i][param] ) {
            retArr.splice(i, 1);
        } else {
            i++;
        }
    }
}

The idea of automatic filter by id-like parameter is OK but this feature should be optional.

Example of problem test case: We have something like MyModel.findAll({parentId: xxx}) in our code but we don't have parentId property on MyModel class. For us parentId is just search parameter. We handle it in our custom filter passed to $.fixture.make. However code from fixutre.js filters out all our fixtures because they don't have parentId property and we can't turn this behavior off.