]> git.openstreetmap.org Git - rails.git/commitdiff
Remove name parameter from auth button helpers
authorAnton Khorev <tony29@yandex.ru>
Tue, 16 Jul 2024 14:12:17 +0000 (17:12 +0300)
committerAnton Khorev <tony29@yandex.ru>
Tue, 16 Jul 2024 14:12:17 +0000 (17:12 +0300)
app/helpers/user_helper.rb
app/views/application/_auth_providers.html.erb
test/helpers/user_helper_test.rb

index 734a266db0bcaee9e9061f4d0ce2f4454d04a37b..5863a9403820b7e6bfa622d5c07aa21d587f0418 100644 (file)
@@ -52,29 +52,29 @@ module UserHelper
 
   # External authentication support
 
-  def auth_button(name, provider, options = {})
+  def auth_button(provider, options = {})
     link_to(
-      image_tag("#{name}.svg",
-                :alt => t("application.auth_providers.#{name}.alt"),
+      image_tag("#{provider}.svg",
+                :alt => t("application.auth_providers.#{provider}.alt"),
                 :class => "rounded-1",
                 :size => "36"),
       auth_path(options.merge(:provider => provider)),
       :method => :post,
       :class => "auth_button btn btn-light p-2",
-      :title => t("application.auth_providers.#{name}.title")
+      :title => t("application.auth_providers.#{provider}.title")
     )
   end
 
-  def auth_button_preferred(name, provider, options = {})
+  def auth_button_preferred(provider, options = {})
     link_to(
-      image_tag("#{name}.svg",
-                :alt => t("application.auth_providers.#{name}.alt"),
+      image_tag("#{provider}.svg",
+                :alt => t("application.auth_providers.#{provider}.alt"),
                 :class => "rounded-1 me-3",
-                :size => "36") + t("application.auth_providers.#{name}.title"),
+                :size => "36") + t("application.auth_providers.#{provider}.title"),
       auth_path(options.merge(:provider => provider)),
       :method => :post,
       :class => "auth_button btn btn-outline-secondary border py-2 px-4 d-flex justify-content-center align-items-center",
-      :title => t("application.auth_providers.#{name}.title")
+      :title => t("application.auth_providers.#{provider}.title")
     )
   end
 
index 4577da66845108eca2b9860df2c43a7a8a9dac7c..89de3b4ffbf63a19f01ae08f9ce3d523d1d90911 100644 (file)
@@ -16,7 +16,7 @@
         <% %w[google facebook microsoft github wikipedia].each do |provider| %>
           <% if Settings.key?("#{provider}_auth_id".to_sym) -%>
             <% if @preferred_auth_provider == provider %>
-              <%= auth_button_preferred provider, provider %>
+              <%= auth_button_preferred provider %>
             <% end %>
           <% end -%>
         <% end -%>
@@ -35,7 +35,7 @@
       <% %w[google facebook microsoft github wikipedia].each do |provider| %>
         <% unless @preferred_auth_provider == provider %>
           <% if Settings.key?("#{provider}_auth_id".to_sym) -%>
-            <%= auth_button provider, provider %>
+            <%= auth_button provider %>
           <% end -%>
         <% end %>
       <% end -%>
index 53b9a823bc6476804b53b2736c39e112d83b3fe7..c4020dd7f489dae05d157646e25e735110402627 100644 (file)
@@ -110,7 +110,7 @@ class UserHelperTest < ActionView::TestCase
   end
 
   def test_auth_button
-    button = auth_button("google", "google")
+    button = auth_button("google")
     img_tag = "<img alt=\"Google logo\" class=\"rounded-1\" src=\"/images/google.svg\" width=\"36\" height=\"36\" />"
     assert_equal("<a class=\"auth_button btn btn-light p-2\" title=\"Log in with Google\" rel=\"nofollow\" data-method=\"post\" href=\"/auth/google\">#{img_tag}</a>", button)
   end