Skip to content
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

Handle active model formatted request data properly #187

Conversation

ccleung
Copy link
Contributor

@ccleung ccleung commented Apr 12, 2016

convert the root key from my-model-name to my_model_name so that we access the data properly.

See issue #165 for more detail

@danielspaniel
Copy link
Collaborator

This was good idea ..
Overall I am a bit sad about mockCreate .. it needs some lovin' .. even more than you have given it .. so if you have any other good ideas .. send em my way!
One more thing, this does pass tests .. but do you you think you could add one to show that this works so it does not get broken in the future?

@ccleung ccleung force-pushed the fix-mock-create-active-model-adapter branch from 0aff8ea to eb03b6a Compare April 12, 2016 15:52
@ccleung
Copy link
Contributor Author

ccleung commented Apr 12, 2016

@danielspaniel added tests in updated commit

@danielspaniel
Copy link
Collaborator

with added tests, the build is failing for some reason .. can you check it out?

@ccleung
Copy link
Contributor Author

ccleung commented Apr 12, 2016

yeah it looks like DS.RESTAdapter test is failing because the root key is camelCase instead of under_score

@danielspaniel
Copy link
Collaborator

I thought that might happen .. if it's not easy to fix I can help out later today.

@ccleung
Copy link
Contributor Author

ccleung commented Apr 12, 2016

seems like there is no way to differentiate between ActiveModelAdapter and RESTAdapter now? https://github.com/danielspaniel/ember-data-factory-guy/blob/master/addon/builder/fixture-builder-factory.js , im trying to figure out how to differentiate the two cases, so we can camelCase for RESTAdapter, and under_score for ActiveModelAdapter

@danielspaniel
Copy link
Collaborator

They both do the same thing, but they are calling out to get a tranformer for an attribute ( lets say ) .. and that will depend on the adapter type, but the two fixture builders don't have to know what that is. So, for you, you need the payload key ( or something like that ) .. so maybe try and ask the fixtureBuilder ( add a method ? ) because it has the adapter all setup, and then maybe adapter.payloadKey(modelName) might do it. ??

@ccleung
Copy link
Contributor Author

ccleung commented Apr 12, 2016

yeah ill try that thanks

@ccleung
Copy link
Contributor Author

ccleung commented Apr 12, 2016

Doesn't look like the adapter class has any methods for figuring out the root key, seems like something i can put into fixtureBuilder's, but that means that we may need to introduce an ActiveModelFixtureBuilder instance, that will have a 'payloadKey' that works differently from RESTFixtureBuilder, would that be okay? ActiveModelFixtureBuilder will extend RESTFixtureBuilder and the only different would be the implementation of the new payloadKey method

@danielspaniel
Copy link
Collaborator

Sorry .. I was wrong about adapter, it's serializer

http://emberjs.com/api/data/classes/DS.RESTSerializer.html#method_payloadKeyFromModelName

@ccleung ccleung force-pushed the fix-mock-create-active-model-adapter branch from eb03b6a to 1e80648 Compare April 12, 2016 19:58
@ccleung
Copy link
Contributor Author

ccleung commented Apr 12, 2016

@danielspaniel updated, thanks for the feedback and help

@danielspaniel danielspaniel merged commit 7a07638 into adopted-ember-addons:master Apr 12, 2016
@danielspaniel
Copy link
Collaborator

Thanks for hanging in there! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants