@tomhughes requested changes on this pull request.

The changes I've suggested fix the failing tests, but they also reveal a 
problem as they show that the structure of the JSON returned by the two methods 
is not consistent - one has a top level hash with a `osm` member pointing at 
the details and the other has a top level hash with a `gpx_files` member 
pointing at an array of details.

Looking at other API methods the responses should probably look like:

```json
{
  "version": "0.6",
  "generator": "OpenStreetMap server",
  "copyright": "OpenStreetMap and contributors",
  "attribution": "http://www.openstreetmap.org/copyright";,
  "license": "http://opendatacommons.org/licenses/odbl/1-0/";,
  "trace": {
    ...
  }
}
```
and:

```json
{
  "version": "0.6",
  "generator": "OpenStreetMap server",
  "copyright": "OpenStreetMap and contributors",
  "attribution": "http://www.openstreetmap.org/copyright";,
  "license": "http://opendatacommons.org/licenses/odbl/1-0/";,
  "traces": [
    {
      "trace": {
        ...
      }
    },
    ...
  ]
}
```

> @@ -0,0 +1,3 @@
+json.osm do
+  json.partial! "api/traces/trace", trace => @trace

```suggestion
  json.partial! "api/traces/trace", :trace => @trace
```

> @@ -0,0 +1,3 @@
+json.gpx_files @traces do |trace|
+  json.partial! "api/traces/trace", trace => trace

```suggestion
  json.partial! "api/traces/trace", :trace => trace
```

> +      assert_equal public_trace_file.id, js.id
+      assert_equal public_trace_file.user.id, js.uid

```suggestion
      assert_equal public_trace_file.id, js["osm"]["id"]
      assert_equal public_trace_file.user.id, js["osm"]["uid"]
```

> +        assert_equal trace1.id, js[0]["id"]
+        assert_equal trace2.id, js[1]["id"]

```suggestion
        assert_equal trace1.id, js["gpx_files"][0]["id"]
        assert_equal trace2.id, js["gpx_files"][1]["id"]
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5943#pullrequestreview-2788123048
You are receiving this because you are subscribed to this thread.

Message ID: 
<openstreetmap/openstreetmap-website/pull/5943/review/2788123...@github.com>
_______________________________________________
rails-dev mailing list
rails-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to