I have an Ember route that fetches it's model from the store (ember-data) and then needs to reload it from the server to populate attributes that were not sent on the index
action.
To implement this, I added an afterModel
hook into the router, and called model.reload()
. In the UI, it works brilliantly; the index action loads all the items with partial data, and clicking into the detail requests the rest of the attributes from the server.
However, when I attempt to run integration tests using capybara-webkit or selenium, the route does not transition. The url changes, but the new view is not rendered.
I placed console.log
statements in the model
, afterModel
, and setupController
actions in the route; the model
action does not appear to fire. However, if I remove the afterModel
hook from the router, model
still does not fire, but the route transitions properly. As a user in a web browser, model
, afterModel
, and setupController
all fire, and the route transitions with a fully populated model.
Router code:
Prm.LeadRoute = Ember.Route.extend
setupController: (controller, model) ->
console.log 'setupController'
@controllerFor('newNote').set('model', @store.createRecord('note'))
@controllerFor('newCustomLeadEmail').set('model', @store.createRecord('customLeadEmail'))
@controllerFor('newLeadQuote').set('model', @store.createRecord('leadQuote'))
console.log model
console.log model.get('id')
model.reload()
controller.set('model', model)
model: (params) ->
console.log 'model'
selectedLead = @store.find('lead', params.lead_id)
@controllerFor('property').set('selectedLead', selectedLead)
selectedLead
afterModel: (model) ->
console.log 'afterModel'
model.reload()
deactivate: ->
@controllerFor('property').set('selectedLead', null)
EDIT: Here's the 'transition code'. It's nothing special; we're just clicking a link and letting the Ember router handle the url:
<h2 {{action 'selectLead' lead}}>
{{#linkTo 'lead' lead}}{{unbound bookingRequestName}}{{/linkTo}}
</h2>