Skip to content

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

@LazyDev2k

Description

@LazyDev2k

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions