Decoupling api ready from state.

Api ready is by default to not ready. When requests succeed then it is set to ready.
pull/12037/head
nobuti 8 years ago
parent 8e3d46452d
commit 0c1afbdd64

@ -2,7 +2,8 @@
"rules": {},
"env": {
"es6": true,
"browser": true
"browser": true,
"jasmine": true
},
"extends": "semistandard"
}

@ -17,6 +17,7 @@ var QuotaInfo = Backbone.Collection.extend({
});
this._state = 'unfetched';
this._ready = 'notready';
},
fetch: function (options) {
@ -28,6 +29,7 @@ var QuotaInfo = Backbone.Collection.extend({
this.SQL.execute(SERVICE_QUOTA_QUERY, null, {
success: function (data) {
this._state = 'fetched';
this._ready = 'ready';
this._onFetchSuccess(data);
this._success && this._success();
}.bind(this),
@ -56,7 +58,7 @@ var QuotaInfo = Backbone.Collection.extend({
},
isReady: function () {
return this.getState() === 'fetched';
return this._ready === 'ready';
},
needsCheck: function () {

@ -40,7 +40,7 @@ describe('cartodb3/data/analyses', function () {
describe('data observatory', function () {
afterEach(function () {
DataServicesApiCheck.get(this.configModel)._state = 'fetched';
DataServicesApiCheck.get(this.configModel)._ready = 'ready';
});
var findDataObservatory = function (models) {
@ -50,14 +50,14 @@ describe('cartodb3/data/analyses', function () {
};
it('dataservices api existing', function () {
DataServicesApiCheck.get(this.configModel)._state = 'fetched';
DataServicesApiCheck.get(this.configModel)._ready = 'ready';
var analysisModels = analyses.getAnalysesByModalCategory('create_clean', this.configModel);
expect(analysisModels.length).toBe(4);
expect(findDataObservatory(analysisModels).length).toBe(1);
});
it('dataservices api not existing', function () {
DataServicesApiCheck.get(this.configModel)._state = 'error';
DataServicesApiCheck.get(this.configModel)._ready = 'notready';
var analysisModels = analyses.getAnalysesByModalCategory('create_clean', this.configModel);
expect(analysisModels.length).toBe(3);
expect(findDataObservatory(analysisModels).length).toBe(0);

Loading…
Cancel
Save