Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

failing test of embedded records in a filter

  • Loading branch information...
commit 696bb9b24fc5baed938f87b57eef6579ef96ee48 1 parent 7da1b29
@jefflab authored
Showing with 35 additions and 1 deletion.
  1. +35 −1 packages/ember-data/tests/integration/store_adapter_test.js
View
36 packages/ember-data/tests/integration/store_adapter_test.js
@@ -12,7 +12,7 @@
*/
var get = Ember.get, set = Ember.set;
-var Person, store, adapter;
+var Person, Dog, store, adapter;
module("DS.Store and DS.Adapter integration test", {
setup: function() {
@@ -357,6 +357,40 @@ test("the filter method can optionally take a server query as well", function()
deepEqual(filter.toArray(), [ tom ], "The filter has a single entry in it");
});
+test("the filter method with server query works with embedded records", function() {
+ Dog = DS.Model.extend({
+ name: DS.attr('string')
+ });
+
+ Person.reopen({
+ dogs: DS.hasMany(Dog)
+ });
+
+ DS.Adapter.map(Person, {
+ dogs: { embedded: 'always' }
+ });
+
+ adapter.findQuery = function(store, type, query, array) {
+ array.load([
+ {
+ id: 1,
+ name: "Tom Dale",
+ dogs: [ { name: "Tank" }, { name: "Fluffy" } ]
+ }
+ ]);
+ };
+
+ var filter = store.filter(Person, { name: "Tom Dale" }, function(data) {
+ return data.get('name') === "Tom Dale";
+ });
+
+ equal(get(filter, 'length'), 1, "The filter has an item in it");
+
+ var tom = filter.objectAt(0);
+ equal(tom.get('dogs.length'), 2, "loads embedded records");
+ equal(tom.get('dogs').objectAt(0).get('name'), 'Tank', "loads embedded record attributes");
+});
+
test("can rollback after sucessives updates", function() {
store.load(Person, 1, {name: "Paul Chavard"});
store.set('adapter', 'App.adapter');
Please sign in to comment.
Something went wrong with that request. Please try again.