Commit f6a5771
Changed files (14)
app
adapters
models
templates
config
tests
unit
app/adapters/application.js
@@ -0,0 +1,6 @@
+import DS from 'ember-data';
+
+export default DS.RESTAdapter.extend({
+ namespace: 'api/v2',
+ host: 'http://localhost:3000'
+});
app/models/cake.js
@@ -0,0 +1,8 @@
+import DS from 'ember-data';
+
+export default DS.Model.extend({
+ name: DS.attr('string'),
+ description: DS.attr('string'),
+ createdAt: DS.attr('date'),
+ updatedAt: DS.attr('date'),
+});
app/routes/cakes/index.js
@@ -0,0 +1,7 @@
+import Ember from 'ember';
+
+export default Ember.Route.extend({
+ model: function() {
+ return this.store.find('cake');
+ }
+});
app/routes/cake.js
@@ -0,0 +1,7 @@
+import Ember from 'ember';
+
+export default Ember.Route.extend({
+ model: function(params) {
+ return this.store.find('cake', params.cake_id);
+ }
+});
app/templates/cakes/index.hbs
@@ -0,0 +1,14 @@
+<ul>
+ {{#each}}
+ <li>
+ {{#link-to 'cake' this}}
+ {{name}}
+ {{description}}
+ {{/link-to}}
+ </li>
+ {{else}}
+ <li>No cakes found.</li>
+ {{/each}}
+</ul>
+
+{{outlet}}
app/templates/application.hbs
@@ -1,3 +1,9 @@
<h2 id='title'>Welcome to Ember.js</h2>
+<ul>
+ <li>{{link-to 'Home' 'index'}}</li>
+ <li>{{link-to 'Cakes' 'cakes'}}</li>
+</ul>
+
+<hr />
{{outlet}}
app/templates/cake.hbs
@@ -0,0 +1,7 @@
+<h1>{{name}}</h1>
+<p>{{description}}</p>
+
+<p>Created at: {{createdAt}}</p>
+<p>Updated at: {{updatedAt}}</p>
+
+{{outlet}}
app/router.js
@@ -6,6 +6,9 @@ var Router = Ember.Router.extend({
});
Router.map(function() {
+ this.resource('cakes', function() {
+ this.resource('cake', { path: '/:cake_id' });
+ });
});
export default Router;
config/environment.js
@@ -25,6 +25,9 @@ module.exports = function(environment) {
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
ENV.APP.LOG_VIEW_LOOKUPS = true;
+ ENV.contentSecurityPolicy = {
+ 'connect-src': "'self' http://localhost:3000"
+ }
}
if (environment === 'test') {
tests/unit/adapters/application-test.js
@@ -0,0 +1,15 @@
+import {
+ moduleFor,
+ test
+} from 'ember-qunit';
+
+moduleFor('adapter:application', 'ApplicationAdapter', {
+ // Specify the other units that are required for this test.
+ // needs: ['serializer:foo']
+});
+
+// Replace this with your real tests.
+test('it exists', function() {
+ var adapter = this.subject();
+ ok(adapter);
+});
tests/unit/models/cake-test.js
@@ -0,0 +1,15 @@
+import {
+ moduleForModel,
+ test
+} from 'ember-qunit';
+
+moduleForModel('cake', 'Cake', {
+ // Specify the other units that are required for this test.
+ needs: []
+});
+
+test('it exists', function() {
+ var model = this.subject();
+ // var store = this.store();
+ ok(!!model);
+});
tests/unit/routes/cakes/index-test.js
@@ -0,0 +1,14 @@
+import {
+ moduleFor,
+ test
+} from 'ember-qunit';
+
+moduleFor('route:cakes/index', 'CakesIndexRoute', {
+ // Specify the other units that are required for this test.
+ // needs: ['controller:foo']
+});
+
+test('it exists', function() {
+ var route = this.subject();
+ ok(route);
+});
tests/unit/routes/cake-test.js
@@ -0,0 +1,14 @@
+import {
+ moduleFor,
+ test
+} from 'ember-qunit';
+
+moduleFor('route:cake', 'CakeRoute', {
+ // Specify the other units that are required for this test.
+ // needs: ['controller:foo']
+});
+
+test('it exists', function() {
+ var route = this.subject();
+ ok(route);
+});
package.json
@@ -23,11 +23,11 @@
"broccoli-ember-hbs-template-compiler": "^1.6.1",
"ember-cli": "0.1.2",
"ember-cli-content-security-policy": "0.3.0",
- "ember-export-application-global": "^1.0.0",
"ember-cli-ic-ajax": "0.1.1",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-qunit": "0.1.0",
"ember-data": "1.0.0-beta.10",
+ "ember-export-application-global": "^1.0.0",
"express": "^4.8.5",
"glob": "^4.0.5"
}