Skip to content

Commit

Permalink
Added eager association skipping test
Browse files Browse the repository at this point in the history
Expected it to fail as I've had problems with this type of request
(geddy#249), but was unable to replicate, the test is passing here.
  • Loading branch information
danfinlay committed Feb 6, 2015
1 parent 63833b6 commit 69ec169
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/integration/adapters/sql/eager_assn.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,42 @@ tests = {
});
}

, 'test eager fetching with skip': function (next) {
model.Schedule.all(function (err, schedules) {
if (err) { throw err; }
// Grab the first five items
var scheduleList = schedules.slice(0, 5);
model.FunActivity.all({}, {sort: {id: 'desc'}}, function (err, activities) {
if (err) { throw err; }
// Give each schedule item four associated FunActivities
var interval = 4
, start = 0
, end = 4;
scheduleList.forEach(function (schedule) {
activities.slice(start, end).forEach(function (activity) {
schedule.addFunActivity(activity);
});
start += interval;
end += interval;
});
helpers.updateItems(scheduleList, function (err) {
if (err) { throw err; }

model.Schedule.all({}, {
includes: 'funActivities',
limit: 2,
skip: 2,
sort: {'createdAt':'asc'}
}, function (err, results) {
if (err) { throw err; }
assert.equal(2, results.length, 'Two results should remain');
next();
});
});
});
});
}

};

module.exports = tests;
Expand Down

0 comments on commit 69ec169

Please sign in to comment.