diff --git a/js/id/core/connection.js b/js/id/core/connection.js index 4f07e6d85..7cd2299a9 100644 --- a/js/id/core/connection.js +++ b/js/id/core/connection.js @@ -211,16 +211,25 @@ iD.Connection = function() { }; }; + connection.changesetTags = function(comment, imagery_used) { + var tags = { + imagery_used: imagery_used.join(';'), + created_by: 'iD ' + iD.version + }; + + if (comment) { + tags.comment = comment; + } + + return tags; + }; + connection.putChangeset = function(changes, comment, imagery_used, callback) { oauth.xhr({ method: 'PUT', path: '/api/0.6/changeset/create', options: { header: { 'Content-Type': 'text/xml' } }, - content: JXON.stringify(connection.changesetJXON({ - imagery_used: imagery_used.join(';'), - comment: comment, - created_by: 'iD ' + iD.version - })) + content: JXON.stringify(connection.changesetJXON(connection.changesetTags(comment, imagery_used))) }, function(err, changeset_id) { if (err) return callback(err); oauth.xhr({ diff --git a/test/spec/core/connection.js b/test/spec/core/connection.js index 830bc4247..805649159 100644 --- a/test/spec/core/connection.js +++ b/test/spec/core/connection.js @@ -190,4 +190,10 @@ describe('iD.Connection', function () { ]); }); }); + + describe('#changesetTags', function() { + it('omits comment when empty', function() { + expect(c.changesetTags('', [])).not.to.have.property('comment'); + }) + }) });