Browse Source

Remove default_layers_set flag!

After refactoring, this flag is no longer needed, as all areas of the
code that care about layers do so by setting a key within clean.types,
and then the types helper intelligently combines those together later.
pull/221/head
Julian Simioni 9 years ago
parent
commit
6f92189519
  1. 4
      sanitiser/_layers.js
  2. 3
      test/unit/query/search.js
  3. 4
      test/unit/sanitiser/reverse.js
  4. 5
      test/unit/sanitiser/search.js
  5. 1
      test/unit/sanitiser/suggest.js

4
sanitiser/_layers.js

@ -16,9 +16,9 @@ function sanitize( req ){
}
// default case (no layers specified in GET params)
// don't even set the from_layers key in this case
if('string' !== typeof params.layers || !params.layers.length){
params.layers = 'poi,admin,address'; // default layers
clean.default_layers_set = true;
return { 'error': false };
}
// decide which layers can be queried

3
test/unit/query/search.js

@ -275,7 +275,6 @@ module.exports.tests.query = function(test, common) {
size: 10,
details: true,
parsed_input: parser.get_parsed_address(address),
default_layers_set: true
});
var expected = {
@ -477,7 +476,6 @@ module.exports.tests.query = function(test, common) {
size: 10,
details: true,
parsed_input: parser.get_parsed_address(partial_address),
default_layers_set: true
});
var expected = {
@ -645,7 +643,6 @@ module.exports.tests.query = function(test, common) {
size: 10,
details: true,
parsed_input: parser.get_parsed_address(partial_address),
default_layers_set: true
});
var expected = {

4
test/unit/sanitiser/reverse.js

@ -6,16 +6,14 @@ var suggest = require('../../../sanitiser/reverse'),
defaultError = 'missing param \'lat\'',
defaultClean = { lat:0,
types: {
from_layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood',
'locality', 'local_admin', 'osmaddress', 'openaddresses' ],
},
lon: 0,
size: 10,
details: true,
default_layers_set: true,
categories: []
},
sanitize = function(query, cb) { _sanitize({'query':query}, cb); };
var all_layers = ( '../../query/indeces' );
module.exports.tests = {};

5
test/unit/sanitiser/search.js

@ -9,15 +9,10 @@ var search = require('../../../sanitiser/search'),
defaultError = 'invalid param \'input\': text length, must be >0',
defaultClean = { input: 'test',
types: {
from_layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood',
'locality', 'local_admin', 'osmaddress', 'openaddresses' ],
from_address_parsing: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood',
'locality', 'local_admin', 'osmaddress', 'openaddresses' ],
},
size: 10,
details: true,
parsed_input: defaultParsed,
default_layers_set: true
},
sanitize = function(query, cb) { _sanitize({'query':query}, cb); };

1
test/unit/sanitiser/suggest.js

@ -15,7 +15,6 @@ var suggest = require('../../../sanitiser/suggest'),
lat:0,
lon:0,
parsed_input: defaultParsed,
default_layers_set: true
},
sanitize = function(query, cb) { _sanitize({'query':query}, cb); };

Loading…
Cancel
Save