<p></p>
<p><b>@tomhughes</b> requested changes on this pull request.</p>
<p dir="auto">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 <code class="notranslate">osm</code> member pointing at the details and the other has a top level hash with a <code class="notranslate">gpx_files</code> member pointing at an array of details.</p>
<p dir="auto">Looking at other API methods the responses should probably look like:</p>
<div class="highlight highlight-source-json" dir="auto"><pre class="notranslate">{
<span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>0.6<span class="pl-pds">"</span></span>,
<span class="pl-ent">"generator"</span>: <span class="pl-s"><span class="pl-pds">"</span>OpenStreetMap server<span class="pl-pds">"</span></span>,
<span class="pl-ent">"copyright"</span>: <span class="pl-s"><span class="pl-pds">"</span>OpenStreetMap and contributors<span class="pl-pds">"</span></span>,
<span class="pl-ent">"attribution"</span>: <span class="pl-s"><span class="pl-pds">"</span>http://www.openstreetmap.org/copyright<span class="pl-pds">"</span></span>,
<span class="pl-ent">"license"</span>: <span class="pl-s"><span class="pl-pds">"</span>http://opendatacommons.org/licenses/odbl/1-0/<span class="pl-pds">"</span></span>,
<span class="pl-ent">"trace"</span>: {
<span class="pl-ii">...</span>
}
}</pre></div>
<p dir="auto">and:</p>
<div class="highlight highlight-source-json" dir="auto"><pre class="notranslate">{
<span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>0.6<span class="pl-pds">"</span></span>,
<span class="pl-ent">"generator"</span>: <span class="pl-s"><span class="pl-pds">"</span>OpenStreetMap server<span class="pl-pds">"</span></span>,
<span class="pl-ent">"copyright"</span>: <span class="pl-s"><span class="pl-pds">"</span>OpenStreetMap and contributors<span class="pl-pds">"</span></span>,
<span class="pl-ent">"attribution"</span>: <span class="pl-s"><span class="pl-pds">"</span>http://www.openstreetmap.org/copyright<span class="pl-pds">"</span></span>,
<span class="pl-ent">"license"</span>: <span class="pl-s"><span class="pl-pds">"</span>http://opendatacommons.org/licenses/odbl/1-0/<span class="pl-pds">"</span></span>,
<span class="pl-ent">"traces"</span>: [
{
<span class="pl-ent">"trace"</span>: {
<span class="pl-ii">...</span>
}
},
<span class="pl-ii">...</span>
]
}</pre></div><hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5943#discussion_r2056520337">app/views/api/traces/show.json.jbuilder</a>:</p>
<pre style='color:#555'>> @@ -0,0 +1,3 @@
+json.osm do
+ json.partial! "api/traces/trace", trace => @trace
</pre>
⬇️ Suggested change
<pre style="color: #555">- json.partial! "api/traces/trace", trace => @trace
+ json.partial! "api/traces/trace", :trace => @trace
</pre>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5943#discussion_r2056520628">app/views/api/users/traces/index.json.jbuilder</a>:</p>
<pre style='color:#555'>> @@ -0,0 +1,3 @@
+json.gpx_files @traces do |trace|
+ json.partial! "api/traces/trace", trace => trace
</pre>
⬇️ Suggested change
<pre style="color: #555">- json.partial! "api/traces/trace", trace => trace
+ json.partial! "api/traces/trace", :trace => trace
</pre>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5943#discussion_r2056526101">test/controllers/api/traces_controller_test.rb</a>:</p>
<pre style='color:#555'>> + assert_equal public_trace_file.id, js.id
+ assert_equal public_trace_file.user.id, js.uid
</pre>
⬇️ Suggested change
<pre style="color: #555">- assert_equal public_trace_file.id, js.id
- assert_equal public_trace_file.user.id, js.uid
+ assert_equal public_trace_file.id, js["osm"]["id"]
+ assert_equal public_trace_file.user.id, js["osm"]["uid"]
</pre>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5943#discussion_r2056529282">test/controllers/api/users/traces_controller_test.rb</a>:</p>
<pre style='color:#555'>> + assert_equal trace1.id, js[0]["id"]
+ assert_equal trace2.id, js[1]["id"]
</pre>
⬇️ Suggested change
<pre style="color: #555">- assert_equal trace1.id, js[0]["id"]
- assert_equal trace2.id, js[1]["id"]
+ assert_equal trace1.id, js["gpx_files"][0]["id"]
+ assert_equal trace2.id, js["gpx_files"][1]["id"]
</pre>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5943#pullrequestreview-2788123048">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLIG5CVRR5WRRZUL7QD227C3RAVCNFSM6AAAAAB3R7L6LOVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDOOBYGEZDGMBUHA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLPDTYABHT6ZGYVJHA3227C3RA5CNFSM6AAAAAB3R7L6LOWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTVGF5Q2Q.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/5943/review/2788123048</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/5943#pullrequestreview-2788123048",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5943#pullrequestreview-2788123048",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>