Skip to content

Commit

Permalink
Fix issue where cuisine -> diet upgrades could overwrite existing val…
Browse files Browse the repository at this point in the history
…ues (close #6462)
  • Loading branch information
quincylvania committed May 31, 2019
1 parent d66be6f commit 14c0809
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
10 changes: 5 additions & 5 deletions data/deprecated.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*"},
Expand Down
10 changes: 5 additions & 5 deletions data/taginfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
5 changes: 2 additions & 3 deletions modules/actions/upgrade_tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/spec/actions/upgrade_tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down

0 comments on commit 14c0809

Please sign in to comment.