@pablobm commented on this pull request.
> + js_links = js.dig("user", "social_links")
+ assert_equal user.social_links.count, js_links.count
+ user.social_links.each do |user_link|
+ details = user_link.parsed
+ matching_js_link = js_links.find { |js_link|
+ js_link["url"] == details[:url] && js_link["platform"] ==
details[:platform]
+ }
+ assert_not_nil matching_js_link
+ end
Alternatively, you can sort them first and avoid the nested loop:
```suggestion
ordered_js_links = js.dig("user", "social_links").sort_by { |link|
link["url"] }
ordered_user_links = user.social_links.sort_by(&:url).map(&:parsed)
assert_equal ordered_user_links.count, ordered_js_links.count
ordered_user_links.zip(ordered_js_links).each do |user_link, js_link|
assert_equal user_link[:url], js_link["url"]
assert_equal user_link[:platform], js_link["platform"]
end
```
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6452#pullrequestreview-3375346882
You are receiving this because you are subscribed to this thread.
Message ID:
<openstreetmap/openstreetmap-website/pull/6452/review/[email protected]>_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev