Add a plugin.put() method

Because it exists in GWT implementation of Gerrit JS API

Change-Id: I7fa2501c88de9ce80402595bcff5112c70e07c99
This commit is contained in:
Viktar Donich
2017-09-30 11:56:32 +01:00
parent 80522c3e22
commit a8f7a2823e
2 changed files with 14 additions and 0 deletions

View File

@@ -120,6 +120,16 @@ limitations under the License.
});
});
test('put', () => {
const payload = {foo: 'foo'};
const response = {bar: 'bar'};
getResponseObjectStub.returns(Promise.resolve(response));
return plugin.put('/url', payload, r => {
assert.isTrue(sendStub.calledWith('PUT', '/url', payload));
assert.strictEqual(r, response);
});
});
test('delete works', () => {
const response = {status: 204};
sendStub.returns(Promise.resolve(response));

View File

@@ -157,6 +157,10 @@
return this._send('POST', url, opt_callback, payload);
},
Plugin.prototype.put = function(url, payload, opt_callback) {
return this._send('PUT', url, opt_callback, payload);
},
Plugin.prototype.delete = function(url, opt_callback) {
return getRestAPI().send('DELETE', url).then(response => {
if (response.status !== 204) {