[openstreetmap/openstreetmap-website] Increase tag2link item leniency (PR #6470)
Tom Hughes
notifications at github.com
Tue Oct 28 17:21:45 UTC 2025
@tomhughes commented on this pull request.
> @@ -0,0 +1,57 @@
+# frozen_string_literal: true
+
+module Tag2link
+ class << self
Is there a reason for using this relatively obscure syntax rather than just using `def self.` to define class methods? I find it easier to understand and it's how we generally do it in other places?
> + def test_link_returns_nil_for_unknown_key
+ assert_nil Tag2link.link("nonexistent_key", "SomeValue")
+ end
+
+ def test_link_returns_proper_url_for_known_key
+ url = Tag2link.link("wikidata", "Q936")
+ assert_equal "https://www.wikidata.org/entity/Q936", url
+ end
+
+ def test_build_dict_rejects_deprecated_and_third_party
+ data = [
+ { "key" => "Key:example", "url" => "http://example.com/$1", "rank" => "deprecated", "source" => "osmwiki:P8" },
+ { "key" => "Key:example2", "url" => "http://example2.com/$1", "rank" => "preferred", "source" => "wikidata:P3303" },
+ { "key" => "Key:example3", "url" => "http://example3.com/$1", "rank" => "preferred", "source" => "osmwiki:P8" }
+ ]
+ dict = Tag2link.send(:build_dict, data)
Why the need to use `send` here? It's not a private method?
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6470#pullrequestreview-3389899053
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/6470/review/3389899053 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20251028/4debb758/attachment.htm>
More information about the rails-dev
mailing list