From e9112da3053adcd10b05c2c0a0935a057377381d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 18 May 2017 15:41:41 +0200 Subject: [PATCH 1/3] Going red: add test to check undefined buffersize in requested mapconfig throws error --- test/acceptance/buffer-size-format.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/acceptance/buffer-size-format.js b/test/acceptance/buffer-size-format.js index d5157585..15be2e66 100644 --- a/test/acceptance/buffer-size-format.js +++ b/test/acceptance/buffer-size-format.js @@ -283,7 +283,7 @@ describe('buffer size per format for named maps', function () { }); -describe('buffer size per format for named maps w/o placeholders', function () { +describe.only('buffer size per format for named maps w/o placeholders', function () { var testCases = [ { desc: 'should get png tile using buffer-size 0 overriden by template params', @@ -396,7 +396,23 @@ describe('buffer size per format for named maps w/o placeholders', function () { assert: function (tile, callback) { assert.utfgridEqualsFile(tile, this.fixturePath, 2, callback); } - } + }, + { + desc: 'should get png tile using buffer-size 0 overriden by template params with no buffersize in mapconfig', + coords: { z: 7, x: 64, y: 48 }, + format: 'png', + placeholders: { + buffersize: { + png: 0 + } + }, + fixturePath: './test/fixtures/buffer-size/tile-7.64.48-buffer-size-0.png', + template: createBufferSizeTemplate('named-no-buffer-size-mapconfig-png-0', undefined, {}), + assert: function (tile, callback) { + assert.imageIsSimilarToFile(tile, this.fixturePath, IMAGE_TOLERANCE_PER_MIL, callback); + } + }, + ]; testCases.forEach(function (test) { From 3ce38d7081e002b28d9edcbf7974f1f7a62d614f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 18 May 2017 15:49:57 +0200 Subject: [PATCH 2/3] Going green: fix type error when no buffersize is defined in mapconfig --- .../mapconfig/adapter/mapconfig-buffer-size-adapter.js | 5 +++++ test/acceptance/buffer-size-format.js | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/cartodb/models/mapconfig/adapter/mapconfig-buffer-size-adapter.js b/lib/cartodb/models/mapconfig/adapter/mapconfig-buffer-size-adapter.js index 3296d0ea..7e9e93a1 100644 --- a/lib/cartodb/models/mapconfig/adapter/mapconfig-buffer-size-adapter.js +++ b/lib/cartodb/models/mapconfig/adapter/mapconfig-buffer-size-adapter.js @@ -9,8 +9,13 @@ MapConfigBufferSizeAdapter.prototype.getMapConfig = function (user, requestMapCo return callback(null, requestMapConfig); } + this.formats.forEach(function (format) { if (Number.isFinite(context.templateParams.buffersize[format])) { + if (requestMapConfig.buffersize === undefined) { + requestMapConfig.buffersize = {}; + } + requestMapConfig.buffersize[format] = context.templateParams.buffersize[format]; } }); diff --git a/test/acceptance/buffer-size-format.js b/test/acceptance/buffer-size-format.js index 15be2e66..c32f62d1 100644 --- a/test/acceptance/buffer-size-format.js +++ b/test/acceptance/buffer-size-format.js @@ -283,7 +283,7 @@ describe('buffer size per format for named maps', function () { }); -describe.only('buffer size per format for named maps w/o placeholders', function () { +describe('buffer size per format for named maps w/o placeholders', function () { var testCases = [ { desc: 'should get png tile using buffer-size 0 overriden by template params', @@ -398,7 +398,8 @@ describe.only('buffer size per format for named maps w/o placeholders', function } }, { - desc: 'should get png tile using buffer-size 0 overriden by template params with no buffersize in mapconfig', + desc: 'should get png tile using buffer-size 0' + + ' overriden by template params with no buffersize in mapconfig', coords: { z: 7, x: 64, y: 48 }, format: 'png', placeholders: { From 3978d58d6669a2750e42c7d3414003bbfc4a0190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 18 May 2017 16:12:28 +0200 Subject: [PATCH 3/3] Remove empty line --- .../models/mapconfig/adapter/mapconfig-buffer-size-adapter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/cartodb/models/mapconfig/adapter/mapconfig-buffer-size-adapter.js b/lib/cartodb/models/mapconfig/adapter/mapconfig-buffer-size-adapter.js index 7e9e93a1..aead2d91 100644 --- a/lib/cartodb/models/mapconfig/adapter/mapconfig-buffer-size-adapter.js +++ b/lib/cartodb/models/mapconfig/adapter/mapconfig-buffer-size-adapter.js @@ -9,7 +9,6 @@ MapConfigBufferSizeAdapter.prototype.getMapConfig = function (user, requestMapCo return callback(null, requestMapConfig); } - this.formats.forEach(function (format) { if (Number.isFinite(context.templateParams.buffersize[format])) { if (requestMapConfig.buffersize === undefined) {