From 2f2a3a55f8c58e2e6ddfa327d7ae521c9fd38d6c Mon Sep 17 00:00:00 2001 From: Wyatt Allen Date: Mon, 10 Oct 2016 14:04:20 -0700 Subject: [PATCH] Set topic by Change-Id When setting a topic, GR-CHANGE-METADATA would call the set-topic API endpoint identifying the change using the following format: ~~ When the project or branch contained characters that needed to be URI- encoded, the endpoint would fail to identify the change, resulting in a 404. This API behavior is encoded in Issue 4746. The workaround in this change is to instead identify the change by the shorter Change-Id format (`Ie`), which needs no additional encoding. Bug: Issue 4555 Change-Id: I00181387bc2a85dfea90b9db46fb017749963579 --- .../change/gr-change-metadata/gr-change-metadata.js | 2 +- .../gr-change-metadata/gr-change-metadata_test.html | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js index 28935ce3e4..661a296742 100644 --- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js +++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js @@ -88,7 +88,7 @@ _handleTopicChanged: function(e, topic) { if (!topic.length) { topic = null; } - this.$.restAPI.setChangeTopic(this.change.id, topic); + this.$.restAPI.setChangeTopic(this.change.change_id, topic); }, _computeTopicReadOnly: function(mutable, change) { diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html index 218e124813..22080e8705 100644 --- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html +++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html @@ -85,6 +85,8 @@ limitations under the License. sandbox.stub(element, '_computeValueTooltip').returns(''); sandbox.stub(element, '_computeTopicReadOnly').returns(true); element.change = { + change_id: 'the id', + topic: 'the topic', status: 'NEW', submit_type: 'CHERRY_PICK', labels: { @@ -145,6 +147,13 @@ limitations under the License. done(); }); }); + + test('changing topic calls setChangeTopic', function() { + var topicStub = sandbox.stub(element.$.restAPI, 'setChangeTopic', + function() {}); + element._handleTopicChanged({}, 'the new topic'); + assert.isTrue(topicStub.calledWith('the id', 'the new topic')); + }); }); });