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

this.subject() throws error in moduleForModel if { integration: true } #46

Closed
mitchlloyd opened this issue May 8, 2015 · 9 comments
Closed

Comments

@mitchlloyd
Copy link

I have a test where I was passing { integration: true } in order to use a model with a hasMany relationship. After upgrading from 0.3.1 to 0.3.2, running this.subject() throws an error:

TypeError: Cannot read property 'createRecord' of undefined

I've found that when setting the integration flag, this.container.lookup('store:main') returns undefined. Without the flag, this.container.lookup('store:main') returns a store object.

@rwjblue
Copy link
Member

rwjblue commented May 8, 2015

This is because modelForModel with integration: true is not running the initializers (or the setup code from isolatedContainer).

I think we should be adding all of these registrations from [inside the _setupIntegrationContainer](https://github.com/switchfly/ember-test-helpers/blob/0a514b2367c19cf6f67728629617b63c55128dfc/lib/ember-test-helpers/test-module.js#L222-L238) in addition to calling Ember.Application.buildRegistry`.

@rwjblue
Copy link
Member

rwjblue commented May 8, 2015

We should extract those registrations into a stand alone function, then call it from both isolatedContainer and _setupIntegrationContainer.

@mitchlloyd
Copy link
Author

Thanks for the quick reply! For now I've got a workaround using DS._setupContainer(this.container).

@wagenet
Copy link
Member

wagenet commented May 14, 2015

@rwjblue you also said this was the same as the "missing component:-text-area" stuff, right?

@rwjblue
Copy link
Member

rwjblue commented May 14, 2015

Yes

@nikz
Copy link
Contributor

nikz commented May 17, 2015

Added a failing test for this in #51

@mitchlloyd
Copy link
Author

Does it seem reasonable that Ember and Ember Data could maintain this list of registrations?

For instance, in Ember, this minimal set of container items could be extracted from the application buildRegistry method and be exposed as a public API.

I know that is beyond the scope of this bug, but I just wanted to see if this was a decent idea.

@rwjblue
Copy link
Member

rwjblue commented May 18, 2015

@mitchlloyd - Both Ember Data (in the last couple versions) and Ember (since 1.0.0!) have a mechanism for populating a container with what is needed for a default setup. Unfortunately, we haven't been using them here. I submitted #49 to resolve that, and remove this super annoying hard-coding of registrations/options/etc.

@rwjblue
Copy link
Member

rwjblue commented May 18, 2015

Resolved and released in ember-test-helpers@0.5.0 and ember-qunit@0.4.0.

@rwjblue rwjblue closed this as completed May 18, 2015
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

4 participants