Browse Source

passing in an object (req.clean) instead of a boolean. Plus updated test

pull/103/head
Harish Krishna 10 years ago
parent
commit
14c718bf1c
  1. 2
      controller/doc.js
  2. 2
      controller/search.js
  3. 2
      controller/suggest.js
  4. 3
      helper/geojsonify.js
  5. 6
      test/unit/helper/geojsonify.js

2
controller/doc.js

@ -23,7 +23,7 @@ function setup( backend ){
if( err ){ return next( err ); }
// convert docs to geojson
var geojson = geojsonify( docs, req.clean.details );
var geojson = geojsonify( docs, req.clean );
// response envelope
geojson.date = new Date().getTime();

2
controller/search.js

@ -28,7 +28,7 @@ function setup( backend, query ){
if( err ){ return next( err ); }
// convert docs to geojson
var geojson = geojsonify( docs, req.clean.details );
var geojson = geojsonify( docs, req.clean );
// response envelope
geojson.date = new Date().getTime();

2
controller/suggest.js

@ -27,7 +27,7 @@ function setup( backend, query, query_mixer ){
function reply( docs ){
// convert docs to geojson
var geojson = geojsonify( docs, req.clean.details );
var geojson = geojsonify( docs, req.clean );
// response envelope
geojson.date = new Date().getTime();

3
helper/geojsonify.js

@ -3,7 +3,7 @@ var GeoJSON = require('geojson'),
extent = require('geojson-extent'),
outputGenerator = require('./outputGenerator');
function search( docs, details ){
function search( docs, params ){
// emit a warning if the doc format is invalid
// @note: if you see this error, fix it ASAP!
@ -12,6 +12,7 @@ function search( docs, details ){
return false; // remove offending doc from results
}
var details = params ? params.details : {};
details = details === true || details === 1;
// flatten & expand data for geojson conversion

6
test/unit/helper/geojsonify.js

@ -181,14 +181,14 @@ module.exports.tests.search = function(test, common) {
var truthy_params = [true, 1];
test('geojsonify.search(doc, true) with details', function(t) {
var json = geojsonify.search( input, true );
var json = geojsonify.search( input, { details: true } );
t.deepEqual(json, expected, 'all docs (with details) mapped');
t.end();
});
truthy_params.forEach(function(details) {
test('geojsonify.search(doc, '+ details +') with details', function(t) {
var json = geojsonify.search( input, details );
var json = geojsonify.search( input, { details: details } );
t.deepEqual(json, expected, 'all docs (with details) mapped');
t.end();
});
@ -256,7 +256,7 @@ module.exports.tests.search = function(test, common) {
falsy_params.forEach(function(details) {
test('geojsonify.search(doc, '+ details +') with no details', function(t) {
var json = geojsonify.search( input, details );
var json = geojsonify.search( input, { details: details } );
t.deepEqual(json, no_details_expected, 'all docs (with no details) mapped');
t.end();
});

Loading…
Cancel
Save