diff --git a/lib/cartodb/controllers/base.js b/lib/cartodb/controllers/base.js index 24c06875..2f67ecd2 100644 --- a/lib/cartodb/controllers/base.js +++ b/lib/cartodb/controllers/base.js @@ -10,6 +10,7 @@ var lzmaWorker = new LZMA(); // Whitelist query parameters and attach format var REQUEST_QUERY_PARAMS_WHITELIST = [ 'config', + 'filters', 'map_key', 'api_key', 'auth_token', diff --git a/test/acceptance/widgets.js b/test/acceptance/widgets.js index d2d6652a..7b74e4f6 100644 --- a/test/acceptance/widgets.js +++ b/test/acceptance/widgets.js @@ -183,4 +183,62 @@ describe('widgets', function() { }); }); + describe('filters', function() { + var layergroup = { + version: '1.5.0', + layers: [ + { + type: 'mapnik', + options: { + sql: 'select * from populated_places_simple_reduced', + cartocss: '#layer { marker-fill: red; marker-width: 32; marker-allow-overlap: true; }', + cartocss_version: '2.3.0', + widgets: { + country_places_count: { + type: 'aggregation', + options: { + column: 'adm0_a3', + aggregation: 'count' + } + } + } + } + } + ] + }; + + it("should expose an aggregation", function(done) { + getWidget(layergroup, 'country_places_count', function(err, res) { + if (err) { + return done(err); + } + + var aggregation = JSON.parse(res.body); + assert.equal(aggregation.length, 223); + assert.deepEqual(aggregation[0], { count: 769, adm0_a3: 'USA' }); + + done(); + }); + }); + + it("should expose a filtered aggregation", function(done) { + var filters = { + layers: [ + {country_places_count: {accept: ['CAN']}} + ] + }; + getWidget(layergroup, 'country_places_count', filters, function(err, res) { + if (err) { + return done(err); + } + + var aggregation = JSON.parse(res.body); + assert.equal(aggregation.length, 1); + assert.deepEqual(aggregation[0], { count: 256, adm0_a3: 'CAN' }); + + done(); + }); + }); + }); + });