Simple controller test


#1

Alright, so I am trying to follow along with the ember online documentation and doing something I think is very simple:

                // grab an instance of 'ApplicationController'
                var ctrl = window.App.ApplicationController.create();
                // wrap the test in the run loop because we are dealing with async functions
                Ember.run(function () {
                    // set a generic model on the post controller
                    ctrl.set('model', sampleJsonObject);

                    var canEdit = ctrl.get('canEdit');

                    console.log(canEdit);

                });

Unfortunately the second call to variable ctrl which is a get fails: error ==> TypeError: Object doesn’t support property or method ‘get’

What am I doing wrong?


#2

Here it should be as follows:

// grab an instance of 'ApplicationController'
var ctrl = this.subject();

This would solve your issue.

Thanks.