From 3181bcc63e780003ecaf3490eab39330abf20fc5 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 30 Sep 2015 18:00:54 +0200 Subject: [PATCH] Remove app dependency from controllers --- NEWS.md | 3 +++ lib/cartodb/controllers/layergroup.js | 4 +--- lib/cartodb/controllers/map.js | 4 +--- lib/cartodb/controllers/named_maps.js | 3 +-- lib/cartodb/controllers/named_maps_admin.js | 6 +++--- lib/cartodb/server.js | 5 +---- test/unit/cartodb/ported/tile_stats.test.js | 15 ++++----------- 7 files changed, 14 insertions(+), 26 deletions(-) diff --git a/NEWS.md b/NEWS.md index dc38c41d..0542e51d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,9 @@ Released 2015-mm-dd +Enhancements: + - Remove app dependency from controllers + Announcements: - Upgrades windshaft to [1.0.1](https://github.com/CartoDB/Windshaft/releases/tag/1.0.1) diff --git a/lib/cartodb/controllers/layergroup.js b/lib/cartodb/controllers/layergroup.js index d239278f..9194c05f 100644 --- a/lib/cartodb/controllers/layergroup.js +++ b/lib/cartodb/controllers/layergroup.js @@ -11,7 +11,6 @@ var MapStoreMapConfigProvider = require('../models/mapconfig/map_store_provider' var TablesCacheEntry = require('../cache/model/database_tables_entry'); /** - * @param app * @param {AuthApi} authApi * @param {PgConnection} pgConnection * @param {MapStore} mapStore @@ -24,11 +23,10 @@ var TablesCacheEntry = require('../cache/model/database_tables_entry'); * @param {LayergroupAffectedTables} layergroupAffectedTables * @constructor */ -function LayergroupController(app, authApi, pgConnection, mapStore, tileBackend, previewBackend, attributesBackend, +function LayergroupController(authApi, pgConnection, mapStore, tileBackend, previewBackend, attributesBackend, surrogateKeysCache, userLimitsApi, queryTablesApi, layergroupAffectedTables) { BaseController.call(this, authApi, pgConnection); - this.app = app; this.mapStore = mapStore; this.tileBackend = tileBackend; this.previewBackend = previewBackend; diff --git a/lib/cartodb/controllers/map.js b/lib/cartodb/controllers/map.js index 275fc779..f6391db1 100644 --- a/lib/cartodb/controllers/map.js +++ b/lib/cartodb/controllers/map.js @@ -20,7 +20,6 @@ var NamedMapMapConfigProvider = require('../models/mapconfig/named_map_provider' var CreateLayergroupMapConfigProvider = require('../models/mapconfig/create_layergroup_provider'); /** - * @param app * @param {AuthApi} authApi * @param {PgConnection} pgConnection * @param {TemplateMaps} templateMaps @@ -32,12 +31,11 @@ var CreateLayergroupMapConfigProvider = require('../models/mapconfig/create_laye * @param {LayergroupAffectedTables} layergroupAffectedTables * @constructor */ -function MapController(app, authApi, pgConnection, templateMaps, mapBackend, metadataBackend, queryTablesApi, +function MapController(authApi, pgConnection, templateMaps, mapBackend, metadataBackend, queryTablesApi, surrogateKeysCache, userLimitsApi, layergroupAffectedTables) { BaseController.call(this, authApi, pgConnection); - this.app = app; this.pgConnection = pgConnection; this.templateMaps = templateMaps; this.mapBackend = mapBackend; diff --git a/lib/cartodb/controllers/named_maps.js b/lib/cartodb/controllers/named_maps.js index 6b26ef19..004282c9 100644 --- a/lib/cartodb/controllers/named_maps.js +++ b/lib/cartodb/controllers/named_maps.js @@ -11,11 +11,10 @@ var userMiddleware = require('../middleware/user'); var TablesCacheEntry = require('../cache/model/database_tables_entry'); -function NamedMapsController(app, authApi, pgConnection, namedMapProviderCache, tileBackend, previewBackend, +function NamedMapsController(authApi, pgConnection, namedMapProviderCache, tileBackend, previewBackend, surrogateKeysCache, tablesExtentApi, metadataBackend) { BaseController.call(this, authApi, pgConnection); - this.app = app; this.namedMapProviderCache = namedMapProviderCache; this.tileBackend = tileBackend; this.previewBackend = previewBackend; diff --git a/lib/cartodb/controllers/named_maps_admin.js b/lib/cartodb/controllers/named_maps_admin.js index 1ff411cd..cd17b5c7 100644 --- a/lib/cartodb/controllers/named_maps_admin.js +++ b/lib/cartodb/controllers/named_maps_admin.js @@ -10,16 +10,16 @@ var userMiddleware = require('../middleware/user'); /** - * @param {TemplateMaps} templateMaps * @param {AuthApi} authApi * @param {PgConnection} pgConnection + * @param {TemplateMaps} templateMaps * @constructor */ -function NamedMapsAdminController(templateMaps, authApi, pgConnection) { +function NamedMapsAdminController(authApi, pgConnection, templateMaps) { BaseController.call(this, authApi, pgConnection); - this.templateMaps = templateMaps; this.authApi = authApi; + this.templateMaps = templateMaps; } util.inherits(NamedMapsAdminController, BaseController); diff --git a/lib/cartodb/server.js b/lib/cartodb/server.js index da30e2e2..e7824d2b 100644 --- a/lib/cartodb/server.js +++ b/lib/cartodb/server.js @@ -155,7 +155,6 @@ module.exports = function(serverOptions) { ******************************************************************************************************************/ new controller.Layergroup( - app, authApi, pgConnection, mapStore, @@ -169,7 +168,6 @@ module.exports = function(serverOptions) { ).register(app); new controller.Map( - app, authApi, pgConnection, templateMaps, @@ -182,7 +180,6 @@ module.exports = function(serverOptions) { ).register(app); new controller.NamedMaps( - app, authApi, pgConnection, namedMapProviderCache, @@ -193,7 +190,7 @@ module.exports = function(serverOptions) { metadataBackend ).register(app); - new controller.NamedMapsAdmin(templateMaps, authApi, pgConnection).register(app); + new controller.NamedMapsAdmin(authApi, pgConnection, templateMaps).register(app); new controller.ServerInfo().register(app); diff --git a/test/unit/cartodb/ported/tile_stats.test.js b/test/unit/cartodb/ported/tile_stats.test.js index 2a872eb3..e5ad622d 100644 --- a/test/unit/cartodb/ported/tile_stats.test.js +++ b/test/unit/cartodb/ported/tile_stats.test.js @@ -1,18 +1,13 @@ require('../../../support/test_helper.js'); var assert = require('assert'); -var cartodbServer = require('../../../../lib/cartodb/server'); -var serverOptions = require('../../../../lib/cartodb/server_options'); -var StatsClient = require('../../../../lib/cartodb/stats/client'); var LayergroupController = require('../../../../lib/cartodb/controllers/layergroup'); describe('tile stats', function() { - var statsClientGetInstanceFn = StatsClient.getInstance; - after(function() { - StatsClient.getInstance = statsClientGetInstanceFn; + global.statsClient = null; }); @@ -28,7 +23,7 @@ describe('tile stats', function() { } }); - var layergroupController = new LayergroupController(cartodbServer(serverOptions)); + var layergroupController = new LayergroupController(); var reqMock = { params: { @@ -70,7 +65,7 @@ describe('tile stats', function() { send: function() {} }; - var layergroupController = new LayergroupController(cartodbServer(serverOptions)); + var layergroupController = new LayergroupController(); layergroupController.finalizeGetTileOrGrid('Another error happened', reqMock, resMock, null, null); @@ -79,9 +74,7 @@ describe('tile stats', function() { }); function mockStatsClientGetInstance(instance) { - StatsClient.getInstance = function() { - return instance; - }; + global.statsClient = instance; } });