{"action":"created","issue":{"url":"https://api.github.com/repos/danielspaniel/ember-data-factory-guy/issues/300","repository_url":"https://api.github.com/repos/danielspaniel/ember-data-factory-guy","labels_url":"https://api.github.com/repos/danielspaniel/ember-data-factory-guy/issues/300/labels{/name}","comments_url":"https://api.github.com/repos/danielspaniel/ember-data-factory-guy/issues/300/comments","events_url":"https://api.github.com/repos/danielspaniel/ember-data-factory-guy/issues/300/events","html_url":"https://github.com/danielspaniel/ember-data-factory-guy/issues/300","id":247557901,"number":300,"title":"nested models","user":{"login":"mnifakram","id":2995199,"avatar_url":"https://avatars2.githubusercontent.com/u/2995199?v=4","gravatar_id":"","url":"https://api.github.com/users/mnifakram","html_url":"https://github.com/mnifakram","followers_url":"https://api.github.com/users/mnifakram/followers","following_url":"https://api.github.com/users/mnifakram/following{/other_user}","gists_url":"https://api.github.com/users/mnifakram/gists{/gist_id}","starred_url":"https://api.github.com/users/mnifakram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnifakram/subscriptions","organizations_url":"https://api.github.com/users/mnifakram/orgs","repos_url":"https://api.github.com/users/mnifakram/repos","events_url":"https://api.github.com/users/mnifakram/events{/privacy}","received_events_url":"https://api.github.com/users/mnifakram/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-08-03T00:12:44Z","updated_at":"2017-08-03T03:17:31Z","closed_at":null,"body":"I have nested models like the following:  a `Vehicle` (Super Class) and Two submodels `Car` and `Moto`.\r\n\r\nI defined a factory called `car.js` \r\n\r\n```\r\nimport './vehicle'\r\nFactoryGuy.define('car', {\r\n  extends: 'vehicle',\r\n  default: {\r\n    wheels: 4\r\n  }\r\n});\r\n```\r\nand then in my test I did the following setup:\r\n\r\n```\r\nconst record = make('car');\r\nmockFindRecord('vehicle').returns({ model: record });\r\n```\r\nHere I want to get all the vehicles regardless of the type (`Car` or `Moto`). The mock works well except that it return the object with `modelName=vehicle` which is the argument passed to `mockFindRecord('this is what always get returned')`?  I need the real `modelName` as I have  a component that render based on the `model.constructor.modelName`.\r\n\r\nI found a dirty fix by overriding the `modelName` after [this line](https://github.com/danielspaniel/ember-data-factory-guy/blob/master/addon/mocks/mock-get-request.js#L88)\r\n\r\n```\r\ncase 'model':\r\n        model = options.model;\r\n\r\n        Ember.assert(`argument ( model ) must be a Model instance - found type:'\r\n          ${Ember.typeOf(model)}`, (model instanceof Model));\r\n\r\n        json = { id: model.id };\r\n        modelName = model.constructor.modelName; // this work like a charm\r\n        this.setResponseJson(this.fixtureBuilder.convertForBuild(modelName, json));\r\n        break;\r\n```\r\n\r\nis there a better way to do it? Or at least how to reopen this class and redefine it. thanks"},"comment":{"url":"https://api.github.com/repos/danielspaniel/ember-data-factory-guy/issues/comments/319856867","html_url":"https://github.com/danielspaniel/ember-data-factory-guy/issues/300#issuecomment-319856867","issue_url":"https://api.github.com/repos/danielspaniel/ember-data-factory-guy/issues/300","id":319856867,"user":{"login":"danielspaniel","id":180456,"avatar_url":"https://avatars1.githubusercontent.com/u/180456?v=4","gravatar_id":"","url":"https://api.github.com/users/danielspaniel","html_url":"https://github.com/danielspaniel","followers_url":"https://api.github.com/users/danielspaniel/followers","following_url":"https://api.github.com/users/danielspaniel/following{/other_user}","gists_url":"https://api.github.com/users/danielspaniel/gists{/gist_id}","starred_url":"https://api.github.com/users/danielspaniel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielspaniel/subscriptions","organizations_url":"https://api.github.com/users/danielspaniel/orgs","repos_url":"https://api.github.com/users/danielspaniel/repos","events_url":"https://api.github.com/users/danielspaniel/events{/privacy}","received_events_url":"https://api.github.com/users/danielspaniel/received_events","type":"User","site_admin":false},"created_at":"2017-08-03T03:17:31Z","updated_at":"2017-08-03T03:17:31Z","body":"ok.. that is helpful.  getting warmer.\r\n so is this a call because the person hasMany vehicles and the relationship is async? \r\n of if not tell me more about when/where/how the call is being made ( like from find/findAll ) "}}
{"actor":{"display_login":"danielspaniel"}}