Fix issue where cuisine -> diet upgrades could overwrite existing values (close #6462)

This commit is contained in:
Quincy Morgan
2019-05-31 08:25:29 -04:00
parent d66be6f569
commit 14c0809426
4 changed files with 20 additions and 13 deletions
+5 -5
View File
@@ -230,23 +230,23 @@
},
{
"old": {"cuisine": "gluten-free"},
"replace": {"diet:gluten_free": "yes"}
"replace": {"diet:gluten_free": "*"}
},
{
"old": {"cuisine": "halal"},
"replace": {"diet:halal": "yes"}
"replace": {"diet:halal": "*"}
},
{
"old": {"cuisine": "kosher"},
"replace": {"diet:kosher": "yes"}
"replace": {"diet:kosher": "*"}
},
{
"old": {"cuisine": "vegan"},
"replace": {"diet:vegan": "yes"}
"replace": {"diet:vegan": "*"}
},
{
"old": {"cuisine": "vegetarian"},
"replace": {"diet:vegetarian": "yes"}
"replace": {"diet:vegetarian": "*"}
},
{
"old": {"curb": "*"},
+5 -5
View File
@@ -1802,11 +1802,11 @@
{"key": "craft", "value": "glass", "description": "🄳 ➜ craft=glaziery"},
{"key": "craft", "value": "catering", "description": "🄳 ➜ craft=caterer"},
{"key": "craft", "value": "sculpter", "description": "🄳 ➜ craft=sculptor"},
{"key": "cuisine", "value": "gluten-free", "description": "🄳 ➜ diet:gluten_free=yes"},
{"key": "cuisine", "value": "halal", "description": "🄳 ➜ diet:halal=yes"},
{"key": "cuisine", "value": "kosher", "description": "🄳 ➜ diet:kosher=yes"},
{"key": "cuisine", "value": "vegan", "description": "🄳 ➜ diet:vegan=yes"},
{"key": "cuisine", "value": "vegetarian", "description": "🄳 ➜ diet:vegetarian=yes"},
{"key": "cuisine", "value": "gluten-free", "description": "🄳 ➜ diet:gluten_free=*"},
{"key": "cuisine", "value": "halal", "description": "🄳 ➜ diet:halal=*"},
{"key": "cuisine", "value": "kosher", "description": "🄳 ➜ diet:kosher=*"},
{"key": "cuisine", "value": "vegan", "description": "🄳 ➜ diet:vegan=*"},
{"key": "cuisine", "value": "vegetarian", "description": "🄳 ➜ diet:vegetarian=*"},
{"key": "curb", "description": "🄳 ➜ kerb=*"},
{"key": "drinkable", "description": "🄳 ➜ drinking_water=*"},
{"key": "dropped_kerb", "description": "🄳 ➜ kerb=lowered"},
+2 -3
View File
@@ -30,9 +30,8 @@ export function actionUpgradeTags(entityId, oldTags, replaceTags) {
for (var replaceKey in replaceTags) {
var replaceValue = replaceTags[replaceKey];
if (replaceValue === '*') {
if (tags[replaceKey]) {
// any value is okay and there already
// is one, so don't update it
if (tags[replaceKey] && tags[replaceKey] !== 'no') {
// allow any pre-existing value except `no` (troll tag)
continue;
} else {
// otherwise assume `yes` is okay
+8
View File
@@ -64,6 +64,14 @@ describe('iD.actionUpgradeTags', function () {
expect(graph.entity(entity.id).tags).to.eql({ shop: 'supermarket', name: 'Foo' });
});
it('upgrades a tag with a wildcard replacement and replaces the exisiting "no" value', function () {
var oldTags = { amenity: 'shop' },
newTags = { shop: '*' },
entity = iD.Entity({ tags: { amenity: 'shop', shop: 'no', name: 'Foo' }}),
graph = iD.actionUpgradeTags(entity.id, oldTags, newTags)(iD.coreGraph([entity]));
expect(graph.entity(entity.id).tags).to.eql({ shop: 'yes', name: 'Foo' });
});
it('upgrades a tag from a semicolon-delimited list that has one other value', function () {
var oldTags = { cuisine: 'vegan' },
newTags = { 'diet:vegan': 'yes' },