Skip to content

Commit

Permalink
Added failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
wecc committed Apr 13, 2015
1 parent c71260d commit 2904134
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1435,3 +1435,49 @@ test("metadata is accessible", function() {
});
});
});


test("metadata should be reset between requests", function() {
var counter = 0;

env.adapter.findHasMany = function() {
var data = {
meta: {
foo: 'bar'
},
chapters: [
{ id: '2' },
{ id: '3' }
]
};

ok(true, 'findHasMany should be called twice');

if (counter === 1) {
delete data.meta;
}

counter++;

return resolve(data);
};

var book1, book2;

run(function() {
book1 = env.store.push('book', { id: 1, title: 'Sailing the Seven Seas', links: { chapters: 'chapters' } });
book2 = env.store.push('book', { id: 2, title: 'Another book title', links: { chapters: 'chapters' } });
});

run(function() {
book1.get('chapters').then(function(chapters) {
var meta = chapters.get('meta');
equal(get(meta, 'foo'), 'bar', 'metadata should available');

book2.get('chapters').then(function(chapters) {
var meta = chapters.get('meta');
equal(get(meta, 'foo'), undefined, 'metadata should not be available');
});
});
});
});

0 comments on commit 2904134

Please sign in to comment.