Use project lookup on change starring requests
Change-Id: Iee8de3c68b3f78222a4ef63ba5de680a17033674
(cherry picked from commit f91e636ffb)
This commit is contained in:
committed by
Paladox none
parent
7ebeab7f5b
commit
6cd6fad3e1
@@ -2086,10 +2086,17 @@
|
||||
},
|
||||
|
||||
saveChangeStarred(changeNum, starred) {
|
||||
return this._send({
|
||||
method: starred ? 'PUT' : 'DELETE',
|
||||
url: '/accounts/self/starred.changes/' + changeNum,
|
||||
anonymizedUrl: '/accounts/self/starred.changes/*',
|
||||
// Some servers may require the project name to be provided
|
||||
// alongside the change number, so resolve the project name
|
||||
// first.
|
||||
return this.getFromProjectLookup(changeNum).then(project => {
|
||||
const url = '/accounts/self/starred.changes/' +
|
||||
(project ? encodeURIComponent(project) + '~' : '') + changeNum;
|
||||
return this._send({
|
||||
method: starred ? 'PUT' : 'DELETE',
|
||||
url,
|
||||
anonymizedUrl: '/accounts/self/starred.changes/*',
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -1446,5 +1446,28 @@ limitations under the License.
|
||||
flushAsynchronousOperations();
|
||||
assert.isTrue(handler.calledOnce);
|
||||
});
|
||||
|
||||
test('saveChangeStarred', async () => {
|
||||
sandbox.stub(element, 'getFromProjectLookup')
|
||||
.returns(Promise.resolve('test'));
|
||||
const sendStub =
|
||||
sandbox.stub(element, '_send').returns(Promise.resolve());
|
||||
|
||||
await element.saveChangeStarred(123, true);
|
||||
assert.isTrue(sendStub.calledOnce);
|
||||
assert.deepEqual(sendStub.lastCall.args[0], {
|
||||
method: 'PUT',
|
||||
url: '/accounts/self/starred.changes/test~123',
|
||||
anonymizedUrl: '/accounts/self/starred.changes/*',
|
||||
});
|
||||
|
||||
await element.saveChangeStarred(456, false);
|
||||
assert.isTrue(sendStub.calledTwice);
|
||||
assert.deepEqual(sendStub.lastCall.args[0], {
|
||||
method: 'DELETE',
|
||||
url: '/accounts/self/starred.changes/test~456',
|
||||
anonymizedUrl: '/accounts/self/starred.changes/*',
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user