diff --git a/.jshintrc b/.jshintrc index 08096ef..2f30d16 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,5 +1,6 @@ { "predef": [ + "server", "document", "window", "-Promise" diff --git a/bower.json b/bower.json index 247ad7a..9e3c641 100644 --- a/bower.json +++ b/bower.json @@ -20,6 +20,8 @@ "bootstrap-sass-official": "~3.3.3", "typeahead.js": "~0.10.5", "components-font-awesome": "~4.3.0", - "floatThead": "~1.2.12" + "floatThead": "~1.2.12", + "pretender": "~1.1.0", + "Faker": "~3.1.0" } } diff --git a/mirage/config.js b/mirage/config.js new file mode 100644 index 0000000..83c340e --- /dev/null +++ b/mirage/config.js @@ -0,0 +1,25 @@ +import Mirage, { faker } from 'ember-cli-mirage'; + +export default function() { + + this.urlPrefix = 'http://localhost:3000'; + this.namespace = 'api'; + + // authentication + this.post('/authorizations', (schema, request) => { + if (request.requestBody === 'email=dev%40frolfr.com&password=password') { + return { token: faker.random.uuid() }; + } else { + return new Mirage.Response(422, {}, {}); + } + }); + + // current user + this.get('/users/current', { user: { first_name: 'Joe', last_name: 'Schmoe', email: 'joe.schmoe@noreply.com' } }, 200); + + // current round + this.get('/rounds/current', { rounds: [] }, 200); + + // courses + this.get('/courses', { courses: [] }, 200); +} diff --git a/mirage/scenarios/default.js b/mirage/scenarios/default.js new file mode 100644 index 0000000..0d2db8d --- /dev/null +++ b/mirage/scenarios/default.js @@ -0,0 +1,11 @@ +export default function(/* server */) { + + /* + Seed your development database using your factories. + This data will not be loaded in your tests. + + Make sure to define a factory for each model you want to create. + */ + + // server.createList('post', 10); +} diff --git a/mirage/serializers/application.js b/mirage/serializers/application.js new file mode 100644 index 0000000..6d47a36 --- /dev/null +++ b/mirage/serializers/application.js @@ -0,0 +1,4 @@ +import { JSONAPISerializer } from 'ember-cli-mirage'; + +export default JSONAPISerializer.extend({ +}); diff --git a/package.json b/package.json index 4e18d0f..5c54f96 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "ember-cli-htmlbars-inline-precompile": "^0.3.1", "ember-cli-ic-ajax": "0.2.4", "ember-cli-inject-live-reload": "^1.3.1", + "ember-cli-mirage": "0.2.1", "ember-cli-pagination": "^0.6.6", "ember-cli-qunit": "^1.0.4", "ember-cli-release": "0.2.8", diff --git a/tests/.jshintrc b/tests/.jshintrc index fab5aca..2a171aa 100644 --- a/tests/.jshintrc +++ b/tests/.jshintrc @@ -1,5 +1,6 @@ { "predef": [ + "server", "document", "window", "location", diff --git a/tests/helpers/destroy-app.js b/tests/helpers/destroy-app.js index c3d4d1a..3a0114a 100644 --- a/tests/helpers/destroy-app.js +++ b/tests/helpers/destroy-app.js @@ -2,4 +2,5 @@ import Ember from 'ember'; export default function destroyApp(application) { Ember.run(application, 'destroy'); + server.shutdown(); }