]> git.openstreetmap.org Git - rails.git/commitdiff
Using ruby helpers to construct html, changed div to span
authorŠtefan Baebler <stefan.baebler@gmail.com>
Mon, 19 Mar 2018 09:51:21 +0000 (10:51 +0100)
committerŠtefan Baebler <stefan.baebler@gmail.com>
Mon, 19 Mar 2018 09:51:21 +0000 (10:51 +0100)
app/helpers/browse_helper.rb
test/helpers/browse_helper_test.rb

index 1fce5f0b3e296bd979de7052b4f66704d2a58bb9..2f07fd2ebe3278e45b05b1759458ea34551e4dc5 100644 (file)
@@ -77,7 +77,7 @@ module BrowseHelper
     elsif url = telephone_link(key, value)
       link_to h(value), url, :title => t("browse.tag_details.telephone_link", :phone_number => value)
     elsif colour_value = colour_preview(key, value)
-      %( <div class="colour-preview-box" style="background-color:#{h(value)}" title="#{h(t('browse.tag_details.colour_preview', :colour_value => colour_value))}"></div>#{h(value)} ).html_safe # rubocop:disable Rails/OutputSafety
+      content_tag(:span, "", :class => "colour-preview-box", :style => "background-color:#{colour_value}", :title => t("browse.tag_details.colour_preview", :colour_value => colour_value)) + colour_value
     else
       linkify h(value)
     end
index 4cb7c4853b03baaf977795afa8dae666c4cf60d3..2bfdf5cb1262974d1e66be49925902d6a23d6249 100644 (file)
@@ -136,7 +136,7 @@ class BrowseHelperTest < ActionView::TestCase
     assert_dom_equal "<a title=\"The Q123 item on Wikidata\" href=\"//www.wikidata.org/wiki/Q123?uselang=en\">Q123</a>", html
 
     html = format_value("colour", "#f00")
-    assert_dom_equal %( <div class="colour-preview-box" style="background-color:#f00" title="Colour #f00 preview"></div>#f00 ), html
+    assert_dom_equal %(<span class="colour-preview-box" style="background-color:#f00" title="Colour #f00 preview"></span>#f00), html
   end
 
   def test_icon_tags