From 65af872ec68f02281d8760a23aa0760a225f0d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 3 Sep 2014 16:48:48 +0200 Subject: [PATCH] Small fix to graphiteDatasource and sending cacheTimeout undefined, reintroduced this bug yesterday, added unit test so it should not appear again --- src/app/services/graphite/graphiteDatasource.js | 4 +++- src/test/specs/graphiteDatasource-specs.js | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/services/graphite/graphiteDatasource.js b/src/app/services/graphite/graphiteDatasource.js index 9a450c2a0c6..62f0bdabedb 100644 --- a/src/app/services/graphite/graphiteDatasource.js +++ b/src/app/services/graphite/graphiteDatasource.js @@ -251,7 +251,9 @@ function (angular, _, $, config, kbn, moment) { _.each(options, function (value, key) { if ($.inArray(key, graphite_options) === -1) { return; } - clean_options.push(key + "=" + encodeURIComponent(value)); + if (value) { + clean_options.push(key + "=" + encodeURIComponent(value)); + } }); return clean_options; diff --git a/src/test/specs/graphiteDatasource-specs.js b/src/test/specs/graphiteDatasource-specs.js index a6a9c892601..49ebba9bebf 100644 --- a/src/test/specs/graphiteDatasource-specs.js +++ b/src/test/specs/graphiteDatasource-specs.js @@ -18,7 +18,7 @@ define([ var query = { range: { from: 'now-1h', to: 'now' }, targets: [{ target: 'prod1.count' }, {target: 'prod2.count'}], - maxDataPoints: 500 + maxDataPoints: 500, }; var response = [{ target: 'prod1.count', points: [[10, 1], [12,1]], }]; @@ -46,6 +46,11 @@ define([ expect(params).to.contain('until=now'); }); + it('should exclude undefined params', function() { + var params = request.split('&'); + expect(params).to.not.contain('cacheTimeout=undefined'); + }); + it('should return series list', function() { expect(results.data.length).to.be(1); expect(results.data[0].target).to.be('prod1.count');