From: Simon Legner Date: Wed, 9 Mar 2016 18:46:03 +0000 (+0000) Subject: Show ref of object when no name is present X-Git-Tag: live~4479 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/6f144e8b7dbedab09042f461bd55d357c8896612?hp=bb489ed5a3c5f2bc0de73b36f516d417095bfed5 Show ref of object when no name is present --- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b317054b6..651691b84 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -85,7 +85,7 @@ Metrics/MethodLength: # Offense count: 1 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 129 + Max: 131 # Offense count: 4 # Configuration parameters: CountKeywordArgs. diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 8f2ce5da7..494232744 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -25,6 +25,8 @@ module BrowseHelper name = t "printable_name.with_name_html", :name => content_tag(:bdi, object.tags["name:#{locale}"].to_s), :id => content_tag(:bdi, name) elsif object.tags.include? "name" name = t "printable_name.with_name_html", :name => content_tag(:bdi, object.tags["name"].to_s), :id => content_tag(:bdi, name) + elsif object.tags.include? "ref" + name = t "printable_name.with_name_html", :name => content_tag(:bdi, object.tags["ref"].to_s), :id => content_tag(:bdi, name) end end diff --git a/test/fixtures/current_node_tags.yml b/test/fixtures/current_node_tags.yml index 38b941e3c..d299998b5 100644 --- a/test/fixtures/current_node_tags.yml +++ b/test/fixtures/current_node_tags.yml @@ -57,3 +57,8 @@ nwn_shop: node_id: 18 k: 'shop' v: 'gift' + +nwrwn_ref: + node_id: 19 + k: 'ref' + v: '3.1415926' diff --git a/test/fixtures/current_nodes.yml b/test/fixtures/current_nodes.yml index af6ea01d5..8389f67bb 100644 --- a/test/fixtures/current_nodes.yml +++ b/test/fixtures/current_nodes.yml @@ -180,3 +180,13 @@ node_with_name: version: 2 tile: <%= QuadTile.tile_for_point(1,1) %> timestamp: 2007-01-01 00:00:00 + +node_with_ref_without_name: + id: 19 + latitude: <%= 1*SCALE %> + longitude: <%= 1*SCALE %> + changeset_id: 2 + visible: true + version: 1 + tile: <%= QuadTile.tile_for_point(1,1) %> + timestamp: 2007-01-01 00:00:00 diff --git a/test/helpers/browse_helper_test.rb b/test/helpers/browse_helper_test.rb index 7878d10e0..e34af0930 100644 --- a/test/helpers/browse_helper_test.rb +++ b/test/helpers/browse_helper_test.rb @@ -23,6 +23,7 @@ class BrowseHelperTest < ActionView::TestCase assert_dom_equal "18", printable_name(nodes(:node_with_name_redacted_version)) assert_dom_equal "Test Node (18, v2)", printable_name(nodes(:node_with_name_current_version), true) assert_dom_equal "18, v1", printable_name(nodes(:node_with_name_redacted_version), true) + assert_dom_equal "3.1415926 (19)", printable_name(current_nodes(:node_with_ref_without_name)) I18n.locale = "pt" @@ -32,6 +33,7 @@ class BrowseHelperTest < ActionView::TestCase assert_dom_equal "18", printable_name(nodes(:node_with_name_redacted_version)) assert_dom_equal "Nó teste (18, v2)", printable_name(nodes(:node_with_name_current_version), true) assert_dom_equal "18, v1", printable_name(nodes(:node_with_name_redacted_version), true) + assert_dom_equal "3.1415926 (19)", printable_name(current_nodes(:node_with_ref_without_name)) I18n.locale = "pt-BR" @@ -41,6 +43,7 @@ class BrowseHelperTest < ActionView::TestCase assert_dom_equal "18", printable_name(nodes(:node_with_name_redacted_version)) assert_dom_equal "Nó teste (18, v2)", printable_name(nodes(:node_with_name_current_version), true) assert_dom_equal "18, v1", printable_name(nodes(:node_with_name_redacted_version), true) + assert_dom_equal "3.1415926 (19)", printable_name(current_nodes(:node_with_ref_without_name)) I18n.locale = "de" @@ -50,6 +53,7 @@ class BrowseHelperTest < ActionView::TestCase assert_dom_equal "18", printable_name(nodes(:node_with_name_redacted_version)) assert_dom_equal "Test Node (18, v2)", printable_name(nodes(:node_with_name_current_version), true) assert_dom_equal "18, v1", printable_name(nodes(:node_with_name_redacted_version), true) + assert_dom_equal "3.1415926 (19)", printable_name(current_nodes(:node_with_ref_without_name)) end def test_link_class diff --git a/test/models/node_tag_test.rb b/test/models/node_tag_test.rb index d9bce8552..0196b6fef 100644 --- a/test/models/node_tag_test.rb +++ b/test/models/node_tag_test.rb @@ -4,7 +4,7 @@ class NodeTagTest < ActiveSupport::TestCase api_fixtures def test_tag_count - assert_equal 12, NodeTag.count + assert_equal 13, NodeTag.count node_tag_count(:visible_node, 1) node_tag_count(:invisible_node, 1) node_tag_count(:used_node_1, 1) diff --git a/test/models/node_test.rb b/test/models/node_test.rb index c9a897796..ff833d0ed 100644 --- a/test/models/node_test.rb +++ b/test/models/node_test.rb @@ -4,7 +4,7 @@ class NodeTest < ActiveSupport::TestCase api_fixtures def test_node_count - assert_equal 18, Node.count + assert_equal 19, Node.count end def test_node_too_far_north