Permalink
Browse files

Merge pull request #384 from chrismayer/fix-378

Prevent inadvertently repeated callbacks in ProtocolProxy
  • Loading branch information...
2 parents 58eee4b + 9dca7e2 commit fd290823eed80cb306209a4275a1464e50175fe3 @chrismayer chrismayer committed Mar 17, 2016
Showing with 62 additions and 1 deletion.
  1. +2 −1 src/GeoExt/data/proxy/Protocol.js
  2. +37 −0 tests/busstops.geojson
  3. +23 −0 tests/data/proxy/Protocol.html
@@ -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);
@@ -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": ""
+ }
+ }]
+}
@@ -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({

0 comments on commit fd29082

Please sign in to comment.