Skip to content

Commit

Permalink
Merge pull request #384 from chrismayer/fix-378
Browse files Browse the repository at this point in the history
Prevent inadvertently repeated callbacks in ProtocolProxy
  • Loading branch information
chrismayer committed Mar 17, 2016
2 parents 58eee4b + 9dca7e2 commit fd29082
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/GeoExt/data/proxy/Protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ Ext.define('GeoExt.data.proxy.Protocol', {
} else {
operation.setRecords(result.records);
}
operation.setCompleted();

operation.setSuccessful();
operation.setCompleted();
} else {
me.setException(operation, response);
me.fireEvent('exception', this, response, operation);
Expand Down
37 changes: 37 additions & 0 deletions tests/busstops.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": "osm-busstops.fid-450a1ab3_149e7ccb0c9_30ad",
"geometry": {
"type": "Point",
"coordinates": [1218828.5056681812,
6620850.261476886]
},
"geometry_name": "geometry",
"properties": {
"id": 1130170,
"osm_id": 1688977159,
"name": "Salomonsborn",
"type": "bus_stop",
"ref": ""
}
},
{
"type": "Feature",
"id": "osm-busstops.fid-450a1ab3_149e7da3233_e78",
"geometry": {
"type": "Point",
"coordinates": [599198.5191414315,
5359744.431373389]
},
"geometry_name": "geometry",
"properties": {
"id": 1130233,
"osm_id": 1689159158,
"name": "Barbini Loubon",
"type": "bus_stop",
"ref": ""
}
}]
}
23 changes: 23 additions & 0 deletions tests/data/proxy/Protocol.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,29 @@

}

function test_loadViaHttp(t) {
t.plan(2);
// create feature store with ProtocolProxy loading a document
// by HTTP
var store = Ext.create('GeoExt.data.FeatureStore', {
fields: [
{name: 'name', type: 'string'}
],
autoLoad: true,
proxy: Ext.create('GeoExt.data.proxy.Protocol', {
reader: Ext.create('GeoExt.data.reader.Feature', {root: 'features'}),
protocol: new OpenLayers.Protocol.HTTP({
url: "../../busstops.geojson",
format: new OpenLayers.Format.GeoJSON({})
})
})
});
t.delay_call(1, function() {
t.eq(store.getCount(), 2, "proxy loaded the the correct amount of records");
t.eq(store.getAt(0).get('name'), 'Salomonsborn', "feature attributes are mapped correctly to the record");
});
}

function test_readFeatures(t) {
t.plan(1);
var response = new OpenLayers.Protocol.Response({
Expand Down

0 comments on commit fd29082

Please sign in to comment.