Browse Source

Merge pull request #466 from pelias/staging

Merge staging into production
pull/745/head
Julian Simioni 9 years ago
parent
commit
643ab5c24c
  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. 3
      test/unit/sanitiser/reverse.js
  7. 3
      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

@ -5,6 +5,7 @@ var sanitizeAll = require('../sanitiser/sanitizeAll'),
singleScalarParameters: require('../sanitiser/_single_scalar_parameters'), singleScalarParameters: require('../sanitiser/_single_scalar_parameters'),
layers: require('../sanitiser/_targets')('layers', type_mapping.layer_with_aliases_to_type), layers: require('../sanitiser/_targets')('layers', type_mapping.layer_with_aliases_to_type),
sources: require('../sanitiser/_targets')('sources', type_mapping.source_to_type), sources: require('../sanitiser/_targets')('sources', type_mapping.source_to_type),
quattroshapes_warning: require('../sanitiser/_warn_quattroshapes')(),
size: require('../sanitiser/_size'), size: require('../sanitiser/_size'),
private: require('../sanitiser/_flag_bool')('private', false), private: require('../sanitiser/_flag_bool')('private', false),
geo_reverse: require('../sanitiser/_geo_reverse'), geo_reverse: require('../sanitiser/_geo_reverse'),

1
sanitiser/search.js

@ -7,6 +7,7 @@ var sanitizeAll = require('../sanitiser/sanitizeAll'),
size: require('../sanitiser/_size'), size: require('../sanitiser/_size'),
layers: require('../sanitiser/_targets')('layers', type_mapping.layer_with_aliases_to_type), layers: require('../sanitiser/_targets')('layers', type_mapping.layer_with_aliases_to_type),
sources: require('../sanitiser/_targets')('sources', type_mapping.source_to_type), sources: require('../sanitiser/_targets')('sources', type_mapping.source_to_type),
quattroshapes_warning: require('../sanitiser/_warn_quattroshapes')(),
private: require('../sanitiser/_flag_bool')('private', false), private: require('../sanitiser/_flag_bool')('private', false),
geo_search: require('../sanitiser/_geo_search'), geo_search: require('../sanitiser/_geo_search'),
boundary_country: require('../sanitiser/_boundary_country'), 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.' ] json.geocoding.errors.should.eql [ 'You have specified both the `sources` and `layers` parameters in a combination that will return no results.' ]
#? expected warnings #? 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 #? inputs
json.geocoding.query['size'].should.eql 10 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.' ] json.geocoding.errors.should.eql [ 'You have specified both the `sources` and `layers` parameters in a combination that will return no results.' ]
#? expected warnings #? 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 #? inputs
json.geocoding.query['text'].should.eql 'a' json.geocoding.query['text'].should.eql 'a'

3
test/unit/sanitiser/reverse.js

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

3
test/unit/sanitiser/search.js

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

Loading…
Cancel
Save