Adds option to not fetch map when instantiating a windshaft provider.

Closes #74
This commit is contained in:
Raul Ochoa 2014-12-18 17:10:37 +01:00
parent 20b88a72ff
commit 9c5c290c4e
4 changed files with 33 additions and 3 deletions

3
NEWS
View File

@ -1,3 +1,6 @@
2.7.0
- Adds option to not fetch map when instantiating a windshaft provider (#74)
2.6.1 2.6.1
- Fix marker fill opacity (#72) - Fix marker fill opacity (#72)

View File

@ -33,8 +33,9 @@
var e = this.options.extra_params || (this.options.extra_params = {}); var e = this.options.extra_params || (this.options.extra_params = {});
e.auth_token = this.options.auth_token; e.auth_token = this.options.auth_token;
} }
if (!this.options.no_fetch_map) {
this._fetchMap(); this._fetchMap();
}
}; };
json.prototype = { json.prototype = {

View File

@ -1,6 +1,6 @@
{ {
"name": "torque.js", "name": "torque.js",
"version": "2.6.1", "version": "2.7.0",
"description": "Torque javascript library", "description": "Torque javascript library",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -135,4 +135,30 @@ test("auth_token with several params as array param and present in url", functio
ok(lastCall.indexOf("auth_token[]=token2") !== -1); ok(lastCall.indexOf("auth_token[]=token2") !== -1);
}); });
[
{ shouldInvokeFetchMap: true, desc: 'undefined no_fetch_map option provided should invoke _fetchMap' },
{ no_fetch_map: false, shouldInvokeFetchMap: true, desc: 'no_fetch_map=false should invoke _fetchMap' },
{ no_fetch_map: true, shouldInvokeFetchMap: false, desc: 'no_fetch_map=true should NOT invoke _fetchMap' }
].forEach(function(fetchMapCase) {
test("no_fetch_map option: " + fetchMapCase.desc, function() {
var fetchMapFn = torque.providers.windshaft.prototype._fetchMap;
var _fetchMapInvoked = false;
torque.providers.windshaft.prototype._fetchMap = function() {
_fetchMapInvoked = true;
};
new torque.providers.windshaft({
table: 'test',
user: "rambo",
no_fetch_map: fetchMapCase.no_fetch_map
});
equal(_fetchMapInvoked, fetchMapCase.shouldInvokeFetchMap);
torque.providers.windshaft.prototype._fetchMap = fetchMapFn;
});
});