Merge "Rename params variable to optionsHex"
This commit is contained in:
commit
2fc37eb9e8
@ -353,7 +353,7 @@
|
||||
|
||||
/**
|
||||
* @param {string} url
|
||||
* @param {?Object=} opt_params URL params, key-value hash.
|
||||
* @param {?Object|string=} opt_params URL params, key-value hash.
|
||||
* @return {string}
|
||||
*/
|
||||
_urlWithParams(url, opt_params) {
|
||||
@ -1352,30 +1352,32 @@
|
||||
* @param {function()=} opt_cancelCondition
|
||||
*/
|
||||
getDiffChangeDetail(changeNum, opt_errFn, opt_cancelCondition) {
|
||||
const params = this.listChangesOptionsToHex(
|
||||
const optionsHex = this.listChangesOptionsToHex(
|
||||
this.ListChangesOption.ALL_COMMITS,
|
||||
this.ListChangesOption.ALL_REVISIONS,
|
||||
this.ListChangesOption.SKIP_MERGEABLE
|
||||
);
|
||||
return this._getChangeDetail(changeNum, params, opt_errFn,
|
||||
return this._getChangeDetail(changeNum, optionsHex, opt_errFn,
|
||||
opt_cancelCondition);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {string|undefined} optionsHex list changes options in hex
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {function()=} opt_cancelCondition
|
||||
*/
|
||||
_getChangeDetail(changeNum, params, opt_errFn, opt_cancelCondition) {
|
||||
_getChangeDetail(changeNum, optionsHex, opt_errFn, opt_cancelCondition) {
|
||||
return this.getChangeActionURL(changeNum, null, '/detail').then(url => {
|
||||
const urlWithParams = this._urlWithParams(url, params);
|
||||
const urlWithParams = this._urlWithParams(url, optionsHex);
|
||||
const params = {O: optionsHex};
|
||||
const req = {
|
||||
url,
|
||||
errFn: opt_errFn,
|
||||
cancelCondition: opt_cancelCondition,
|
||||
params: {O: params},
|
||||
params,
|
||||
fetchOptions: this._etags.getOptions(urlWithParams),
|
||||
anonymizedUrl: '/changes/*~*/detail?O=' + params,
|
||||
anonymizedUrl: '/changes/*~*/detail?O=' + optionsHex,
|
||||
};
|
||||
return this._fetchRawJSON(req).then(response => {
|
||||
if (response && response.status === 304) {
|
||||
|
@ -1151,12 +1151,12 @@ limitations under the License.
|
||||
test('_getChangeDetail passes params to ETags decorator', () => {
|
||||
const changeNum = 4321;
|
||||
element._projectLookup[changeNum] = 'test';
|
||||
const params = {foo: 'bar'};
|
||||
const expectedUrl =
|
||||
window.CANONICAL_PATH + '/changes/test~4321/detail?foo=bar';
|
||||
window.CANONICAL_PATH + '/changes/test~4321/detail?'+
|
||||
'0=5&1=1&2=6&3=7&4=1&5=4';
|
||||
sandbox.stub(element._etags, 'getOptions');
|
||||
sandbox.stub(element._etags, 'collect');
|
||||
return element._getChangeDetail(changeNum, params).then(() => {
|
||||
return element._getChangeDetail(changeNum, '516714').then(() => {
|
||||
assert.isTrue(element._etags.getOptions.calledWithExactly(
|
||||
expectedUrl));
|
||||
assert.equal(element._etags.collect.lastCall.args[0], expectedUrl);
|
||||
@ -1169,7 +1169,7 @@ limitations under the License.
|
||||
.returns(Promise.resolve(''));
|
||||
sandbox.stub(element, '_fetchRawJSON')
|
||||
.returns(Promise.resolve({ok: false, status: 500}));
|
||||
return element._getChangeDetail(123, {}, errFn).then(() => {
|
||||
return element._getChangeDetail(123, '516714', errFn).then(() => {
|
||||
assert.isTrue(errFn.called);
|
||||
});
|
||||
});
|
||||
@ -1185,7 +1185,7 @@ limitations under the License.
|
||||
parsed: mockResponse,
|
||||
raw: JSON.stringify(mockResponse),
|
||||
}));
|
||||
return element._getChangeDetail(1).then(() => {
|
||||
return element._getChangeDetail(1, '516714').then(() => {
|
||||
assert.equal(Object.keys(element._projectLookup).length, 1);
|
||||
assert.equal(element._projectLookup[1], 'test');
|
||||
});
|
||||
@ -1216,7 +1216,7 @@ limitations under the License.
|
||||
ok: true,
|
||||
}));
|
||||
|
||||
return element._getChangeDetail(123, {}).then(detail => {
|
||||
return element._getChangeDetail(123, '516714').then(detail => {
|
||||
assert.isFalse(getPayloadSpy.called);
|
||||
assert.isTrue(collectSpy.calledOnce);
|
||||
const cachedResponse = element._etags.getCachedPayload(requestUrl);
|
||||
|
Loading…
Reference in New Issue
Block a user