Skip to content

Commit

Permalink
Configure ember-example
Browse files Browse the repository at this point in the history
  • Loading branch information
mwoods79 committed Aug 26, 2015
1 parent 0260b6f commit bd48e5c
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 1 deletion.
7 changes: 7 additions & 0 deletions spec/fixtures/ember-example/app/adapters/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import DS from 'ember-data';
import config from '../config/environment';

export default DS.RESTAdapter.extend({
host: config.API_HOST
});

6 changes: 6 additions & 0 deletions spec/fixtures/ember-example/app/models/todo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import DS from 'ember-data';

export default DS.Model.extend({
title: DS.attr(),
complete: DS.attr("boolean")
});
1 change: 1 addition & 0 deletions spec/fixtures/ember-example/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var Router = Ember.Router.extend({
});

Router.map(function() {
this.route("todos");
});

export default Router;
7 changes: 7 additions & 0 deletions spec/fixtures/ember-example/app/routes/todos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Ember from 'ember';

export default Ember.Route.extend({
model() {
return this.store.findAll("todo");
}
});
9 changes: 9 additions & 0 deletions spec/fixtures/ember-example/app/templates/todos.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{!- app/templates/todos.hbs }}

<h1>Todo List</h1>

{{#each model as |todo|}}
<p class='todo-item'>
{{todo.title}}
</p>
{{/each}}
3 changes: 2 additions & 1 deletion spec/fixtures/ember-example/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"ember-resolver": "~0.1.18",
"jquery": "^1.11.1",
"loader.js": "ember-cli/loader.js#3.2.0",
"qunit": "~1.18.0"
"qunit": "~1.18.0",
"pretender": "^0.9.0"
}
}
6 changes: 6 additions & 0 deletions spec/fixtures/ember-example/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,11 @@ module.exports = function(environment) {

}

if (environment === 'test') {
ENV.API_HOST = ''
} else {
ENV.API_HOST = (process.env.API_HOST || 'http://localhost:3000')
}

return ENV;
};
1 change: 1 addition & 0 deletions spec/fixtures/ember-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"ember-cli-htmlbars-inline-precompile": "^0.1.1",
"ember-cli-ic-ajax": "0.2.1",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-pretender": "0.4.0",
"ember-cli-qunit": "0.3.20",
"ember-cli-release": "0.2.3",
"ember-cli-sri": "^1.0.1",
Expand Down
46 changes: 46 additions & 0 deletions spec/fixtures/ember-example/tests/acceptance/todos-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'ember-example/tests/helpers/start-app';
import Pretender from 'pretender';

let TODOS = [
{id: 1, title: "write a blog post"},
{id: 2, title: "let people read it"},
{id: 3, title: "... profit"}
];

module('Acceptance | todos', {
beforeEach: function() {
this.application = startApp();

this.server = new Pretender(function() {
this.get('/todos', function(){
var json = {
todos: TODOS
};

return [200, {}, JSON.stringify(json)];
});
});
},

afterEach: function() {
Ember.run(this.application, 'destroy');
this.server.shutdown();
}
});

test('visiting /todos', function(assert) {
visit('/todos');

andThen(function() {
var title = find('h1');
assert.equal(title.text(), 'Todo List');

var todos = find('.todo-item');
assert.equal(todos.length, TODOS.length);

assert.equal(currentURL(), '/todos');
});
});

0 comments on commit bd48e5c

Please sign in to comment.