Remove app dependency from controllers

This commit is contained in:
Raul Ochoa 2015-09-30 18:00:54 +02:00
parent bf9cb33d63
commit 3181bcc63e
7 changed files with 14 additions and 26 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;
}
});