-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ var Router = Ember.Router.extend({ | |
}); | ||
|
||
Router.map(function() { | ||
this.route("todos"); | ||
}); | ||
|
||
export default Router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
spec/fixtures/ember-example/tests/acceptance/todos-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); | ||
|