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

FactoryGuy.make() doesn't handle ID relationships, Ember Data does #166

Closed
mmelvin0 opened this issue Dec 23, 2015 · 3 comments
Closed

FactoryGuy.make() doesn't handle ID relationships, Ember Data does #166

mmelvin0 opened this issue Dec 23, 2015 · 3 comments

Comments

@mmelvin0
Copy link
Contributor

If I do this (with parent.children being a hasMany relationship to child):

FactoryGuy.make('child', {id: 1});
FactoryGuy.make('parent', children: [1]);

JSONAPIFixtureConverter.extractRelationships() returns undefined for these relationships.

However, Ember Data itself will look up these IDs and replace them with the child records, if FactoryGuy wasn't replacing the IDs with undefined. Based on the Ember Data behavior - and this worked for our project with Factory Guy 0.9.1 - it seems simple enough to fix.

I'll prepare a pull request, let me know if you have further insight into this.

mmelvin0 added a commit to mmelvin0/ember-data-factory-guy that referenced this issue Dec 23, 2015
mmelvin0 added a commit to mmelvin0/ember-data-factory-guy that referenced this issue Dec 23, 2015
@danielspaniel
Copy link
Collaborator

Thanks for PR, and this is good point, since ED will return that record. The only thing that I would like is a test or two ( to show failure without your change ) to make sure it stays working in the future. If you can slap those tests in the PR I'd be much obliged.

@mmelvin0
Copy link
Contributor Author

A test or two has revealed this is slightly more complicated than I initially thought. Will re-do the pull request by next week (with appropriate tests). Happy holidays!

@mmelvin0
Copy link
Contributor Author

I added several tests, only handle strings and numbers as IDs, and assert the relationship isn't polymorphic.

danielspaniel added a commit that referenced this issue Feb 11, 2016
Return fixture relationship IDs if not an object (fix #166)
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

No branches or pull requests

2 participants