Skip to content

Commit

Permalink
Merge pull request #6210 from AnalyticalGraphicsInc/fix-6206
Browse files Browse the repository at this point in the history
Fixes Resource.prototype.fetch when called with no arguments
  • Loading branch information
Tom Fili authored Feb 12, 2018
2 parents fdedfbe + 5b4b71b commit 9246085
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Change Log

##### Fixes :wrench:
* Fixed bug where AxisAlignedBoundingBox did not copy over center value when cloning an undefined result. [#6183](https://github.com/AnalyticalGraphicsInc/cesium/pull/6183)
* Fixed `Resource.fetch` when called with no arguments [#6206](https://github.com/AnalyticalGraphicsInc/cesium/issues/6206)

### 1.42.1 - 2018-02-01
_This is an npm-only release to fix an issue with using Cesium in Node.js.__
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ define([
* @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}
*/
Resource.prototype.fetch = function(options) {
options = defaultClone(options, defaultValue.EMPTY_OBJECT);
options = defaultClone(options, {});
options.method = 'GET';

return makeRequest(this, options);
Expand Down
19 changes: 19 additions & 0 deletions Specs/Core/ResourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,4 +589,23 @@ defineSuite([
expect(Resource.prototype.fetch).toHaveBeenCalled();
});
});

it('fetch calls correct method', function() {
var expectedUrl = 'http://test.com/endpoint';
var expectedResult = {
status: 'success'
};

spyOn(Resource._Implementations, 'loadWithXhr').and.callFake(function(url, responseType, method, data, headers, deferred, overrideMimeType) {
expect(url).toEqual(expectedUrl);
expect(method).toEqual('GET');
deferred.resolve(expectedResult);
});

var resource = new Resource({url: expectedUrl});
return resource.fetch()
.then(function(result) {
expect(result).toEqual(expectedResult);
});
});
});

0 comments on commit 9246085

Please sign in to comment.