From bf05802b7d996c8e7a799f2d003fd2566a60419f Mon Sep 17 00:00:00 2001 From: Ignacio Baixas Date: Wed, 24 Sep 2014 10:33:46 -0300 Subject: [PATCH] feat(find_many): adds posibility to include additional parameters in populate request --- src/plugins/find-many.js | 4 ++-- test/plugins/find-many-spec.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins/find-many.js b/src/plugins/find-many.js index 4ae3c81..14ada1a 100644 --- a/src/plugins/find-many.js +++ b/src/plugins/find-many.js @@ -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; diff --git a/test/plugins/find-many-spec.js b/test/plugins/find-many-spec.js index ae8ee17..2042fc0 100644 --- a/test/plugins/find-many-spec.js +++ b/test/plugins/find-many-spec.js @@ -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),