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

Get access to ember store from moduleFor("controller:activity") #70

Closed
gogogarrett opened this issue Jun 27, 2014 · 8 comments
Closed

Comments

@gogogarrett
Copy link

I'm trying to get a hold of the store instance to .createRecord('activity', {id: '1_1'}) inside my test, but I can't seem to make it happen. Anyone have any ideas?

I've tried a few different things here

I managed to get a store class, but it's not working as I would like by doing something like..

moduleFor "controller:activity", "Activity Controller"

test "does things", ->
  @container.register "store:main", DS.Store
  store = @container.lookup("store:main")


  Ember.run ->
    activity = store.createRecord('activity', {id: '1_1'})
    ctrl.set 'content', activity


  equal 1,1

but even this doesn't create the activity record as desired.

@fivetanley
Copy link
Member

You might need to pass needs: "store:main", "model:activity" as the last argument to moduleFor

@tmcgilchrist
Copy link

@gogogarrett I've been using store = App.__container__.lookup('store:main') to grab a reference to the store. Which seems to work for your test.

@stefanpenner stefanpenner changed the title Get access to ember store from ModuleFor("controller:activity") Get access to ember store from moduleFor("controller:activity") Oct 15, 2014
@stefanpenner
Copy link
Member

we need a integration testing mode.

@sasZilla
Copy link

Is there any way use "store" in controller and then tested id without use store = App.container.lookup('store:main') ?
For example
moduleFor "controller:activity", "Activity Controller"
test "does things", ->
ctrl = @subject()

where ctrl.get('store') is not undefined

@stefanpenner
Copy link
Member

You can pass a store mock or instance to subject

@tagisen
Copy link

tagisen commented Nov 14, 2014

Yes, I solved this by creating

var store = DS.Store.create({
    adapter: this.subject()
})

And it works just fine.

@pmdarrow
Copy link

@isenbeqiri not sure how your solution applies to the OP's issue? this.subject() in his case would be a controller instance, not an adapter.

@pmdarrow
Copy link

@stefanpenner this could probably be closed in favour of https://github.com/rwjblue/ember-qunit/issues/108.

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

7 participants