mercredi 21 septembre 2016

Ember testing: injecting controller in a component test

I'm facing some issue with one of my component integration test. To explain briefly, my component uses a sub-component which uses some ember-can ability to select options to display.

The abilities are relying on a controller to know which is the current project and so what are the permissions of the user. So in our app.js file, we have something like that:

application.inject('ability', 'projectController', 'controller:project');

Of course, when doing the integration test for the component, the ability is unable to find the controller, nor the project and so always consider the user does not have the required permission.

I tried so far stuff like that:

this.register('controller:project', Ember.Object.create({
  project: this.project
}));
this.inject.controller('controller:project', {as: 'projectController'});

But this does not have any impact on the abilities (the test documentation shows how to inject services but is pretty poor on the controller injection).

Does anyone have a good idea on how to solve that issue ?

Best regards, Vincent




Aucun commentaire:

Enregistrer un commentaire