{"action":"created","issue":{"url":"https://api.github.com/repos/samselikoff/ember-cli-mirage/issues/627","repository_url":"https://api.github.com/repos/samselikoff/ember-cli-mirage","labels_url":"https://api.github.com/repos/samselikoff/ember-cli-mirage/issues/627/labels{/name}","comments_url":"https://api.github.com/repos/samselikoff/ember-cli-mirage/issues/627/comments","events_url":"https://api.github.com/repos/samselikoff/ember-cli-mirage/issues/627/events","html_url":"https://github.com/samselikoff/ember-cli-mirage/issues/627","id":139085498,"number":627,"title":"Acceptance Testing data not being run through the serializer","user":{"login":"Aaronfischer","id":5474591,"avatar_url":"https://avatars.githubusercontent.com/u/5474591?v=3","gravatar_id":"","url":"https://api.github.com/users/Aaronfischer","html_url":"https://github.com/Aaronfischer","followers_url":"https://api.github.com/users/Aaronfischer/followers","following_url":"https://api.github.com/users/Aaronfischer/following{/other_user}","gists_url":"https://api.github.com/users/Aaronfischer/gists{/gist_id}","starred_url":"https://api.github.com/users/Aaronfischer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aaronfischer/subscriptions","organizations_url":"https://api.github.com/users/Aaronfischer/orgs","repos_url":"https://api.github.com/users/Aaronfischer/repos","events_url":"https://api.github.com/users/Aaronfischer/events{/privacy}","received_events_url":"https://api.github.com/users/Aaronfischer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-07T20:30:37Z","updated_at":"2016-03-10T05:56:01Z","closed_at":null,"body":"Currently using mirage 0.2.0 beta 7.\r\n\r\nI've setup /mirage/factories/user.js using a flat structure to generate data for the front-end dummy app, this works great and is serialized via the /mirage/serializers/application.js just fine (which is using the default setup):\r\n```js\r\nimport Mirage, {faker}  from 'ember-cli-mirage';\r\nimport moment from 'moment';\r\n\r\nexport default Mirage.Factory.extend({\r\n  'username'() { return faker.internet.userName(); },\r\n  'emailAddress'() { return faker.internet.email(); },\r\n  'firstName'() { return faker.name.firstName(); },\r\n  'lastName'() { return faker.name.lastName(); },\r\n  'isAdmin'() { return faker.random.arrayElement([true, false]); },\r\n  'createdAt'() { return moment(faker.date.past()).format('YYYY-MM-DD'); },\r\n  'updatedAt'() { return moment(faker.date.past()).format('YYYY-MM-DD'); },\r\n});\r\n```\r\n\r\nI've generated /mirage/models/user.js model (default):\r\n```js\r\nimport { Model } from 'ember-cli-mirage';\r\n\r\nexport default Model.extend({\r\n});\r\n```\r\n\r\nI've created /mirage/fixtures/users.js fixture data which is exporting an array of flat data (same attributes as the fixtures + `id` and `type`):\r\n```js\r\nexport default [\r\n    {\r\n        'id': 1,\r\n        'type': 'users',\r\n        'username': 'YippieKiYay',\r\n        'emailAddress': 'john.mcclane@domain.com',\r\n        'firstName': 'John',\r\n        'lastName': 'McClane',\r\n        'isAdmin': true,\r\n        'createdAt': '2017-01-01',\r\n        'updatedAt': '2017-01-02'\r\n    },\r\n    {\r\n        'id': 2,\r\n        'type': 'users',\r\n        'username': 'YippieKiYay',\r\n        'emailAddress': 'john.mcclane@domain.com',\r\n        'firstName': 'John',\r\n        'lastName': 'McClane',\r\n        'isAdmin': true,\r\n        'createdAt': '2017-01-01',\r\n        'updatedAt': '2017-01-02'\r\n    }\r\n];\r\n```\r\n\r\nIn /mirage/config.js:\r\n```js\r\n...\r\nthis.get('/users');\r\nthis.get('/users/:id');\r\n...\r\n```\r\n\r\n/tests/acceptance/basic-test.js\r\n```js\r\nimport moduleForAcceptance from '../helpers/module-for-acceptance';\r\nimport { test } from 'qunit';\r\n\r\nvar application;\r\n\r\nmoduleForAcceptance('Acceptance: Simple Table');\r\n\r\ntest('Check for expected content /', function(assert) {\r\n    server.loadFixtures('users');\r\n    console.log('server.db.users', server.db.users);\r\n    visit('/');\r\n\r\n    andThen(function() {\r\n        assert.equal(currentPath(), 'index');\r\n\r\n        var cells = find('table tbody tr').eq(0).find('td');\r\n\r\n        assert.equal(cells.eq(0).html(), 'YippieKiYay', 'Check for username');\r\n        assert.equal(cells.eq(1).html(), 'john.mcclane@domain.com', 'Check for email');\r\n        assert.equal(cells.eq(2).html(), 'John', 'Check for first name');\r\n        assert.equal(cells.eq(3).html(), 'McClane', 'Check for last name');\r\n        assert.equal(cells.eq(4).text().trim(), '01/02/2017', 'Check for date');\r\n        assert.equal(cells.eq(5).find('a').text().trim(), 'Edit', 'Check for actions');\r\n    });\r\n});\r\n```\r\n\r\n\r\nThe issue: \r\nWhen setting up an acceptance test using the fixture data if the server.db.users is inspected the array is a flat structure without any \"attributes\" or any kind of structure the serializer should be generating.\r\nShould, when testing, the mirage/serializer/* be used?\r\nIf so, perhaps I have found a bug? Or, I'm missing something when setting up my tests.\r\n\r\n\r\n(The addon I am building and using mirage to populate the dummy/testing data is currently a private repo, eventually this will be public though)"},"comment":{"url":"https://api.github.com/repos/samselikoff/ember-cli-mirage/issues/comments/194685278","html_url":"https://github.com/samselikoff/ember-cli-mirage/issues/627#issuecomment-194685278","issue_url":"https://api.github.com/repos/samselikoff/ember-cli-mirage/issues/627","id":194685278,"user":{"login":"samselikoff","id":2922250,"avatar_url":"https://avatars.githubusercontent.com/u/2922250?v=3","gravatar_id":"","url":"https://api.github.com/users/samselikoff","html_url":"https://github.com/samselikoff","followers_url":"https://api.github.com/users/samselikoff/followers","following_url":"https://api.github.com/users/samselikoff/following{/other_user}","gists_url":"https://api.github.com/users/samselikoff/gists{/gist_id}","starred_url":"https://api.github.com/users/samselikoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samselikoff/subscriptions","organizations_url":"https://api.github.com/users/samselikoff/orgs","repos_url":"https://api.github.com/users/samselikoff/repos","events_url":"https://api.github.com/users/samselikoff/events{/privacy}","received_events_url":"https://api.github.com/users/samselikoff/received_events","type":"User","site_admin":false},"created_at":"2016-03-10T05:56:01Z","updated_at":"2016-03-10T05:56:01Z","body":"Nope, that is correct. Fixtures seed the database (`server.db.users`). Data only passes through the serializer from route handlers. Your shorthand `this.get('/users')` is essentially doing (pseudocode)\r\n\r\n```js\r\nthis.get('/users', (schema) => {\r\n  let users = schema.user.all();\r\n  \r\n  return this.serialize(users);\r\n});\r\n```\r\n\r\nSo, your db should never be seeded with serialized data. But, when your Ember app makes an HTTP request to Mirage, it will get back the data in serialized form."}}