From 6b450a6c132654ef73b5f179efebc4c52b9c97e1 Mon Sep 17 00:00:00 2001 From: Marwin Hochfelsner <50826859+hlfan@users.noreply.github.com> Date: Tue, 17 Jun 2025 06:42:34 +0200 Subject: [PATCH] Rename key_svg_tag to legend_svg_tag in svg_helper --- app/helpers/svg_helper.rb | 2 +- app/views/legend_panes/show.html.erb | 2 +- test/helpers/svg_helper_test.rb | 44 ++++++++++++++-------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/helpers/svg_helper.rb b/app/helpers/svg_helper.rb index 7fb6b4321..fe9e4727f 100644 --- a/app/helpers/svg_helper.rb +++ b/app/helpers/svg_helper.rb @@ -13,7 +13,7 @@ module SvgHelper adjacent_page_svg_tag(dir == "rtl" ? -1 : 1, **) end - def key_svg_tag(**options) + def legend_svg_tag(**options) border_width = options["border"] ? (options["border-width"] || 1) : 0 rect_attrs = { :width => "100%", diff --git a/app/views/legend_panes/show.html.erb b/app/views/legend_panes/show.html.erb index fc3c91f63..2bd27f569 100644 --- a/app/views/legend_panes/show.html.erb +++ b/app/views/legend_panes/show.html.erb @@ -7,7 +7,7 @@ <% if entry["image"] %> <%= image_tag "key/#{layer_name}/#{entry['image']}", :class => "filtered-image d-block mx-auto" %> <% else %> - <%= key_svg_tag :class => "filtered-image d-block mx-auto", **entry %> + <%= legend_svg_tag :class => "filtered-image d-block mx-auto", **entry %> <% end %> diff --git a/test/helpers/svg_helper_test.rb b/test/helpers/svg_helper_test.rb index 25a9e4568..6d445da0d 100644 --- a/test/helpers/svg_helper_test.rb +++ b/test/helpers/svg_helper_test.rb @@ -1,8 +1,8 @@ require "test_helper" class SvgHelperTest < ActionView::TestCase - def test_key_fill - svg = key_svg_tag("width" => 60, "height" => 40, "fill" => "green") + def test_legend_fill + svg = legend_svg_tag("width" => 60, "height" => 40, "fill" => "green") expected = <<~HTML.gsub(/\n\s*/, "") @@ -11,8 +11,8 @@ class SvgHelperTest < ActionView::TestCase assert_dom_equal expected, svg end - def test_key_border - svg = key_svg_tag("width" => 60, "height" => 40, "border" => "red") + def test_legend_border + svg = legend_svg_tag("width" => 60, "height" => 40, "border" => "red") expected = <<~HTML.gsub(/\n\s*/, "") @@ -21,8 +21,8 @@ class SvgHelperTest < ActionView::TestCase assert_dom_equal expected, svg end - def test_key_border_width - svg = key_svg_tag("width" => 60, "height" => 40, "border" => "red", "border-width" => 3) + def test_legend_border_width + svg = legend_svg_tag("width" => 60, "height" => 40, "border" => "red", "border-width" => 3) expected = <<~HTML.gsub(/\n\s*/, "") @@ -31,8 +31,8 @@ class SvgHelperTest < ActionView::TestCase assert_dom_equal expected, svg end - def test_key_border_with_integer_coords - svg = key_svg_tag("width" => 60, "height" => 40, "border" => "red", "border-width" => 2) + def test_legend_border_with_integer_coords + svg = legend_svg_tag("width" => 60, "height" => 40, "border" => "red", "border-width" => 2) expected = <<~HTML.gsub(/\n\s*/, "") @@ -41,8 +41,8 @@ class SvgHelperTest < ActionView::TestCase assert_dom_equal expected, svg end - def test_key_border_fractional_width - svg = key_svg_tag("width" => 60, "height" => 40, "border" => "red", "border-width" => 1.5) + def test_legend_border_fractional_width + svg = legend_svg_tag("width" => 60, "height" => 40, "border" => "red", "border-width" => 1.5) expected = <<~HTML.gsub(/\n\s*/, "") @@ -51,8 +51,8 @@ class SvgHelperTest < ActionView::TestCase assert_dom_equal expected, svg end - def test_key_line - svg = key_svg_tag("width" => 80, "height" => 15, "line" => "blue") + def test_legend_line + svg = legend_svg_tag("width" => 80, "height" => 15, "line" => "blue") expected = <<~HTML.gsub(/\n\s*/, "") @@ -61,8 +61,8 @@ class SvgHelperTest < ActionView::TestCase assert_dom_equal expected, svg end - def test_key_line_width - svg = key_svg_tag("width" => 80, "height" => 15, "line" => "blue", "line-width" => 3) + def test_legend_line_width + svg = legend_svg_tag("width" => 80, "height" => 15, "line" => "blue", "line-width" => 3) expected = <<~HTML.gsub(/\n\s*/, "") @@ -71,8 +71,8 @@ class SvgHelperTest < ActionView::TestCase assert_dom_equal expected, svg end - def test_key_line_with_integer_coords - svg = key_svg_tag("width" => 80, "height" => 20, "line" => "blue") + def test_legend_line_with_integer_coords + svg = legend_svg_tag("width" => 80, "height" => 20, "line" => "blue") expected = <<~HTML.gsub(/\n\s*/, "") @@ -81,8 +81,8 @@ class SvgHelperTest < ActionView::TestCase assert_dom_equal expected, svg end - def test_key_casing - svg = key_svg_tag("width" => 80, "height" => 20, "casing" => "yellow") + def test_legend_casing + svg = legend_svg_tag("width" => 80, "height" => 20, "casing" => "yellow") expected = <<~HTML.gsub(/\n\s*/, "") @@ -91,8 +91,8 @@ class SvgHelperTest < ActionView::TestCase assert_dom_equal expected, svg end - def test_key_casing_width - svg = key_svg_tag("width" => 80, "height" => 20, "casing" => "yellow", "casing-width" => 5) + def test_legend_casing_width + svg = legend_svg_tag("width" => 80, "height" => 20, "casing" => "yellow", "casing-width" => 5) expected = <<~HTML.gsub(/\n\s*/, "") @@ -101,8 +101,8 @@ class SvgHelperTest < ActionView::TestCase assert_dom_equal expected, svg end - def test_key_casing_with_integer_coords - svg = key_svg_tag("width" => 80, "height" => 20, "casing" => "yellow", "casing-width" => 2) + def test_legend_casing_with_integer_coords + svg = legend_svg_tag("width" => 80, "height" => 20, "casing" => "yellow", "casing-width" => 2) expected = <<~HTML.gsub(/\n\s*/, "") -- 2.39.5