Skip to content

Commit

Permalink
feat(find_many): adds posibility to include additional parameters in …
Browse files Browse the repository at this point in the history
…populate request
  • Loading branch information
iobaixas committed Sep 24, 2014
1 parent dcfd37b commit bf05802
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/plugins/find-many.js
Expand Up @@ -55,12 +55,12 @@ angular.module('restmod').factory('restmod.FindMany', ['restmod', 'RMPackerCache
* @param {array} _records Records to resolve.
* @return {Resource} Resource holding the populate promise.
*/
.define('Scope.$populate', function(_records) {
.define('Scope.$populate', function(_records, _params) {

// Extract record pks for non resolved records and build a record map
var pks = [],
recordMap = {},
params = {},
params = _params || {},
model = this.$type,
dummy = model.dummy(true),
record, request;
Expand Down
8 changes: 8 additions & 0 deletions test/plugins/find-many-spec.js
Expand Up @@ -27,6 +27,14 @@ describe('Plugin: Find Many plugin', function() {
expect(bikes[1].brand).toEqual('Yetti');
});

it('should include additional parameters in request', function() {
var bikes = [ Bike.$new(1) ];

Bike.$populate(bikes, { include: 'parts' });
$httpBackend.expectGET('/api/bikes?ids=1&include=parts').respond(200, []);
$httpBackend.flush();
});

it('should not repeat ids in request, but should populate repeated records separatedly', function() {
var bikes = [
Bike.$new(1),
Expand Down

0 comments on commit bf05802

Please sign in to comment.