Fix JavaScript error that could cause validation warnings to appear unexpectedly (close #7166)

Add code test to account for deprecated tags with no replacement
This commit is contained in:
Quincy Morgan
2019-12-31 12:03:57 -05:00
parent c8ce5eb8bb
commit 31941e9389
2 changed files with 13 additions and 2 deletions
+1 -1
View File
@@ -205,7 +205,7 @@ osmEntity.prototype = {
return vals.indexOf(d.old[key]) !== -1;
} else {
if (tags[key] === d.old[key]) {
if (d.old[key] === d.replace[key]) {
if (d.replace && d.old[key] === d.replace[key]) {
return !Object.keys(d.replace).every(function(key) {
return tags[key] === d.replace[key];
});
+12 -1
View File
@@ -55,7 +55,7 @@ describe('iD.validations.outdated_tags', function () {
expect(issues).to.have.lengthOf(0);
});
it('flags deprecated tags', function() {
it('flags deprecated tag with replacement', function() {
createWay({'highway': 'ford'});
var issues = validate();
expect(issues).to.have.lengthOf(1);
@@ -67,6 +67,17 @@ describe('iD.validations.outdated_tags', function () {
expect(issue.entityIds[0]).to.eql('w-1');
});
it('flags deprecated tag with no replacement', function() {
createWay({'highway': 'no'});
var issues = validate();
expect(issues).to.have.lengthOf(1);
var issue = issues[0];
expect(issue.type).to.eql('outdated_tags');
expect(issue.subtype).to.eql('deprecated_tags');
expect(issue.severity).to.eql('warning');
expect(issue.entityIds).to.have.lengthOf(1);
expect(issue.entityIds[0]).to.eql('w-1');
});
it('ignores way with no relations', function() {
createWay({});