Browse Source

Merge branch 'staging'

pull/471/head
Julian Simioni 9 years ago
parent
commit
7a33bdd4ea
  1. 25
      sanitiser/_warn_quattroshapes.js
  2. 1
      sanitiser/reverse.js
  3. 1
      sanitiser/search.js
  4. 2
      test/ciao/reverse/sources_layers_invalid_combo.coffee
  5. 2
      test/ciao/search/sources_layers_invalid_combo.coffee
  6. 4
      test/unit/sanitiser/reverse.js
  7. 2
      test/unit/sanitiser/search.js

25
sanitiser/_warn_quattroshapes.js

@ -0,0 +1,25 @@
var _ = require('lodash');
function setup( paramName, targetMap ) {
return function( raw, clean ){
return sanitize( raw, clean );
};
}
function sanitize( raw, clean, opts ) {
// error & warning messages
var messages = { errors: [], warnings: [] };
if (_.includes(raw.sources, 'quattroshapes') || _.includes(raw.sources, 'qs')) {
messages.warnings.push( 'You are using Quattroshapes as a data source in this query. ' +
'Quattroshapes will be disabled as a data source for Mapzen Search in the next several ' +
'weeks, and is being replaced by Who\'s on First, an actively maintained data project ' +
'based on Quattroshapes. Your existing queries WILL CONTINUE TO WORK for the foreseeable ' +
'future, but results will be coming from Who\'s on First and `sources=quattroshapes` will ' +
'be deprecated. If you have any questions, please email search@mapzen.com.');
}
return messages;
}
module.exports = setup;

1
sanitiser/reverse.js

@ -7,6 +7,7 @@ var sanitizeAll = require('../sanitiser/sanitizeAll'),
sources: require('../sanitiser/_targets')('sources', type_mapping.source_mapping),
// depends on the layers and sources sanitisers, must be run after them
sources_and_layers: require('../sanitiser/_sources_and_layers'),
quattroshapes_warning: require('../sanitiser/_warn_quattroshapes')(),
size: require('../sanitiser/_size'),
private: require('../sanitiser/_flag_bool')('private', false),
geo_reverse: require('../sanitiser/_geo_reverse'),

1
sanitiser/search.js

@ -9,6 +9,7 @@ var sanitizeAll = require('../sanitiser/sanitizeAll'),
sources: require('../sanitiser/_targets')('sources', type_mapping.source_mapping),
// depends on the layers and sources sanitisers, must be run after them
sources_and_layers: require('../sanitiser/_sources_and_layers'),
quattroshapes_warning: require('../sanitiser/_warn_quattroshapes')(),
private: require('../sanitiser/_flag_bool')('private', false),
geo_search: require('../sanitiser/_geo_search'),
boundary_country: require('../sanitiser/_boundary_country'),

2
test/ciao/reverse/sources_layers_invalid_combo.coffee

@ -27,7 +27,7 @@ should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'You have specified both the `sources` and `layers` parameters in a combination that will return no results: the whosonfirst source has nothing in the address layer' ]
#? expected warnings
should.not.exist json.geocoding.warnings
json.geocoding.warnings.should.eql [ 'You are using Quattroshapes as a data source in this query. Quattroshapes will be disabled as a data source for Mapzen Search in the next several weeks, and is being replaced by Who\'s on First, an actively maintained data project based on Quattroshapes. Your existing queries WILL CONTINUE TO WORK for the foreseeable future, but results will be coming from Who\'s on First and `sources=quattroshapes` will be deprecated. If you have any questions, please email search@mapzen.com.' ]
#? inputs
json.geocoding.query['size'].should.eql 10

2
test/ciao/search/sources_layers_invalid_combo.coffee

@ -27,7 +27,7 @@ should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'You have specified both the `sources` and `layers` parameters in a combination that will return no results: the whosonfirst source has nothing in the address layer' ]
#? expected warnings
should.not.exist json.geocoding.warnings
json.geocoding.warnings.should.eql [ 'You are using Quattroshapes as a data source in this query. Quattroshapes will be disabled as a data source for Mapzen Search in the next several weeks, and is being replaced by Who\'s on First, an actively maintained data project based on Quattroshapes. Your existing queries WILL CONTINUE TO WORK for the foreseeable future, but results will be coming from Who\'s on First and `sources=quattroshapes` will be deprecated. If you have any questions, please email search@mapzen.com.' ]
#? inputs
json.geocoding.query['text'].should.eql 'a'

4
test/unit/sanitiser/reverse.js

@ -36,8 +36,8 @@ module.exports.tests.interface = function(test, common) {
module.exports.tests.sanitisers = function(test, common) {
test('check sanitiser list', function (t) {
var expected = ['singleScalarParameters', 'layers', 'sources',
'sources_and_layers', 'size', 'private', 'geo_reverse', 'boundary_country'];
var expected = ['singleScalarParameters', 'layers', 'sources', 'sources_and_layers',
'quattroshapes_warning', 'size', 'private', 'geo_reverse', 'boundary_country'];
t.deepEqual(Object.keys(reverse.sanitiser_list), expected);
t.end();
});

2
test/unit/sanitiser/search.js

@ -25,7 +25,7 @@ module.exports.tests.interface = function(test, common) {
module.exports.tests.sanitisers = function(test, common) {
test('check sanitiser list', function (t) {
var expected = ['singleScalarParameters', 'text', 'size', 'layers', 'sources',
'sources_and_layers', 'private', 'geo_search', 'boundary_country' ];
'sources_and_layers', 'quattroshapes_warning', 'private', 'geo_search', 'boundary_country' ];
t.deepEqual(Object.keys(search.sanitiser_list), expected);
t.end();
});

Loading…
Cancel
Save