add application adapter to simulate REST, using fixtures
authornowmad@nowmads-macbook-pro.local
Thu, 10 Dec 2015 16:50:53 +0100
changeset 42 7d091abf82fd
parent 41 b6815b3d46bd
child 43 4d262bdce7cf
add application adapter to simulate REST, using fixtures
cms/app-client/app/adapters/application.js
cms/app-client/app/routes/application.js
cms/app-client/tests/unit/adapters/application-test.js
cms/app-client/tests/unit/routes/application-test.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/app/adapters/application.js	Thu Dec 10 16:50:53 2015 +0100
@@ -0,0 +1,16 @@
+import DS from 'ember-data';
+
+export default DS.FixtureAdapter.extend({
+  host: 'http://127.0.0.1',
+  namespace: 'api',
+  queryFixtures: function(records, query, type) {
+    return records.filter(function(record) {
+        for(var key in query) {
+            if (!query.hasOwnProperty(key)) { continue; }
+            var value = query[key];
+            if (record[key] !== value) { return false; }
+        }
+        return true;
+    });
+  }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/app/routes/application.js	Thu Dec 10 16:50:53 2015 +0100
@@ -0,0 +1,7 @@
+import Ember from 'ember';
+
+export default Ember.Route.extend({
+  model() {
+    return this.store.findAll('sound');
+  }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/tests/unit/adapters/application-test.js	Thu Dec 10 16:50:53 2015 +0100
@@ -0,0 +1,12 @@
+import { moduleFor, test } from 'ember-qunit';
+
+moduleFor('adapter:application', 'Unit | Adapter | application', {
+  // Specify the other units that are required for this test.
+  // needs: ['serializer:foo']
+});
+
+// Replace this with your real tests.
+test('it exists', function(assert) {
+  var adapter = this.subject();
+  assert.ok(adapter);
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/tests/unit/routes/application-test.js	Thu Dec 10 16:50:53 2015 +0100
@@ -0,0 +1,11 @@
+import { moduleFor, test } from 'ember-qunit';
+
+moduleFor('route:application', 'Unit | Route | application', {
+  // Specify the other units that are required for this test.
+  // needs: ['controller:foo']
+});
+
+test('it exists', function(assert) {
+  var route = this.subject();
+  assert.ok(route);
+});