Skip to content

Commit

Permalink
Merge pull request emberjs#1337 from tstirrat/feature/query-meta-support
Browse files Browse the repository at this point in the history
findQuery populates meta hash in AdapterPopulatedRecordArrays
  • Loading branch information
wycats committed Sep 24, 2013
2 parents 7991107 + 638a7bb commit de17e0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Expand Up @@ -22,11 +22,13 @@ DS.AdapterPopulatedRecordArray = DS.RecordArray.extend({
load: function(data) {
var store = get(this, 'store'),
type = get(this, 'type'),
records = store.pushMany(type, data);
records = store.pushMany(type, data),
meta = store.metadataFor(type);

this.setProperties({
content: Ember.A(records),
isLoaded: true
isLoaded: true,
meta: meta
});

// TODO: does triggering didLoad event should be the last action of the runLoop?
Expand Down
Expand Up @@ -512,6 +512,14 @@ test("metadata is accessible", function() {
}));
});

test("findQuery - payload 'meta' is accessible on the record array", function() {
ajaxResponse({ meta: { offset: 5 }, posts: [{id: 1, name: "Rails is very expensive sushi"}] });

store.findQuery('post', { page: 2 }).then(async(function(posts) {
equal(posts.get('meta.offset'), 5, "Reponse metadata can be accessed with recordArray.meta");
}));
});

test("findQuery - returning an array populates the array", function() {
ajaxResponse({ posts: [{ id: 1, name: "Rails is omakase" }, { id: 2, name: "The Parley Letter" }] });

Expand Down

0 comments on commit de17e0f

Please sign in to comment.