Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Resource.prototype.fetch when called with no arguments #6210

Merged
merged 1 commit into from
Feb 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});
});