-
-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
payload of handleFind limited to record's typeKey #82
Comments
Best thing you can do is do fork this project, make the code how you like it, write tests to prove it works, send me a pull request, and away you go with your new version of factory-guy .. Or you could alway override mapFind: FactoryGuyTestHelper.reopen({
mapFind:function(modelName, json){
var responseJson = {};
if (modelName === 'paper-editor-task') {
modelName = 'task';
}
responseJson[Ember.String.pluralize(modelName)] = json;
return responseJson;
}
}); which is alittle bit funky .. but works. |
@danielspaniel Heh, that's exactly what I have right now :) I was just wondering if it was something you were interested in supporting before I sent you a PR demanding you merge it :P |
Sure, I would support some way to modify that modelName .. but I am not sure how you are going to do it .. kind of tricky to do in a generic way .. ( I think ) .. but if you can figure it out .. I will merge it .. ( if you have it tested properly ) |
@tonywok, v2.0.1 removes mapFind from the creation of json .. so if you upgrade, you have to find another path to fix these kinds of issues, but I refactored things to use serializer to create the keys, so maybe it will have fixed itself in this new version? not sure. |
@danielspaniel I'll let my previous client know so they can address accordingly. Thanks for the update :) |
The API I'm working with uses single table inheritance. For example, we have a base task model, and various subclasses.
In my test I'm trying to do a
handleFind(task)
. That task happens to be of typepaper-editor-task
. The factory guy methodmapFind
will always return a json payload keyed to the pluralized version of the model name resulting inpaperEditorTasks
. My ember app expectstasks
.As a workaround I've monkey patched the FactoryGuy code. Would you consider supporting this? Perhaps as an option to
handleFind
? Or maybe by looking into the model's serializer instead of always usingrecord.constructor.typeKey
.The text was updated successfully, but these errors were encountered: