{"action":"opened","issue":{"url":"https://api.github.com/repos/ember-cli/ember-cli/issues/3010","labels_url":"https://api.github.com/repos/ember-cli/ember-cli/issues/3010/labels{/name}","comments_url":"https://api.github.com/repos/ember-cli/ember-cli/issues/3010/comments","events_url":"https://api.github.com/repos/ember-cli/ember-cli/issues/3010/events","html_url":"https://github.com/ember-cli/ember-cli/issues/3010","id":54581087,"number":3010,"title":"Unit Tests: Mocks, Models and Jack Daniels","user":{"login":"agentVargas2012R","id":5995919,"avatar_url":"https://avatars.githubusercontent.com/u/5995919?v=3","gravatar_id":"","url":"https://api.github.com/users/agentVargas2012R","html_url":"https://github.com/agentVargas2012R","followers_url":"https://api.github.com/users/agentVargas2012R/followers","following_url":"https://api.github.com/users/agentVargas2012R/following{/other_user}","gists_url":"https://api.github.com/users/agentVargas2012R/gists{/gist_id}","starred_url":"https://api.github.com/users/agentVargas2012R/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agentVargas2012R/subscriptions","organizations_url":"https://api.github.com/users/agentVargas2012R/orgs","repos_url":"https://api.github.com/users/agentVargas2012R/repos","events_url":"https://api.github.com/users/agentVargas2012R/events{/privacy}","received_events_url":"https://api.github.com/users/agentVargas2012R/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-16T14:31:20Z","updated_at":"2015-01-16T14:31:20Z","closed_at":null,"body":"Hey Guys,\r\n\r\nI'm really trying to figure out how to write a unit test for my controllers method. The model which is referred to in the method is using the ember data restful adapter. \r\n\r\n```javascript\r\ndriveYouToDrink: function(){\r\n            var controller = this;\r\n\r\n            controller.set('show', true);\r\n            controller.set('selectedContact', 1);\r\n\r\n            controller.debug();\r\n\r\n            var contact_id  = ApplyParameterDefault(con_id, controller.get(\"TEST_CONTACT_ID\"));\r\n\r\n            this.store.find(\"leadInteraction\",{contact_id: contact_id}).then(function(resolve, reject){\r\n                   controller.debug();\r\n                   HandleErrorMessage(controller, reject);\r\n\r\n                   var leadsInteractionCtrl                 = controller.get(controller.get('DEPENDENCY_CONTROLLER'));\r\n                   var leadInteractions                     = GenerateEmberArray(resolve);\r\n\r\n                   leadsInteractionCtrl.setProperties({\r\n                       model: leadInteractions,\r\n                       leadInteractions: leadInteractions\r\n                   });\r\n                   controller.set('leadsInteractionCtrl', leadsInteractionCtrl);\r\n                   controller.set('leadInteractions', leadInteractions);\r\n                   controller.set('testPropertyAccess', 'interactionModal');\r\n\r\n            });\r\n}\r\n```\r\n\r\nHere, in my unit test I'm specifying the needs method. It seems to only accept needs: ['lead-interaction'] and not needs: ['leadsInteraction']. The store, however, doesn't understand either of these models\r\n\r\n```javascript\r\nmoduleFor('controller:interaction-source', 'InteractionSourceController', {\r\n  // Specify the other units that are required for this test.\r\n  // needs: ['controller:foo']\r\n   needs: [ 'model:lead-interaction','controller:application', 'controller:contactmanagement/lead-interaction' ]\r\n});\r\n\r\ntest('capturing an interaction', function(){\r\n  var controller = this.subject();\r\n  container = new Ember.Container();\r\n  container.register('store:main', DS.Store.extend());\r\n  store = container.lookup('store:main');\r\n\r\n  controller.store = store;\r\n  debugger;\r\n  controller.send('captureInteraction',1001, 1);\r\n\r\n});\r\n\r\n```\r\nQuestion - How are we suppose to mock the store and its corresponding models in a unit test? What does the set up look for a method which involves the store calling and retrieving objects?\r\n\r\n\r\n"}}