Replace link with button in OmniAuth form component

- and modified spec
This commit is contained in:
cyrillefr
2025-04-03 19:41:32 +02:00
parent 3f9ae66e94
commit bc912b53da
3 changed files with 30 additions and 31 deletions

View File

@@ -8,10 +8,9 @@
<div class="oauth-logins small-12"> <div class="oauth-logins small-12">
<% oauth_logins.each do |login| %> <% oauth_logins.each do |login| %>
<div class="oauth-login"> <div class="oauth-login">
<%= link_to t("omniauth.#{login}.name"), send("user_#{login}_omniauth_authorize_path"), <%= button_to t("omniauth.#{login}.name"), send("user_#{login}_omniauth_authorize_path"),
title: t("omniauth.#{login}.#{action}"), title: t("omniauth.#{login}.#{action}"),
class: "button-#{login.to_s.delete_suffix("_oauth2")} button expanded", class: "button-#{login.to_s.delete_suffix("_oauth2")} button expanded" %>
method: :post %>
</div> </div>
<% end %> <% end %>
</div> </div>

View File

@@ -22,8 +22,8 @@ describe Devise::OmniauthFormComponent do
render_inline component render_inline component
expect(page).to have_link "Twitter" expect(page).to have_button "Twitter"
expect(page).to have_link count: 1 expect(page).to have_button count: 1
end end
it "renders the facebook link when the feature is enabled" do it "renders the facebook link when the feature is enabled" do
@@ -31,8 +31,8 @@ describe Devise::OmniauthFormComponent do
render_inline component render_inline component
expect(page).to have_link "Facebook" expect(page).to have_button "Facebook"
expect(page).to have_link count: 1 expect(page).to have_button count: 1
end end
it "renders the google link when the feature is enabled" do it "renders the google link when the feature is enabled" do
@@ -40,8 +40,8 @@ describe Devise::OmniauthFormComponent do
render_inline component render_inline component
expect(page).to have_link "Google" expect(page).to have_button "Google"
expect(page).to have_link count: 1 expect(page).to have_button count: 1
end end
it "renders the wordpress link when the feature is enabled" do it "renders the wordpress link when the feature is enabled" do
@@ -49,8 +49,8 @@ describe Devise::OmniauthFormComponent do
render_inline component render_inline component
expect(page).to have_link "Wordpress" expect(page).to have_button "Wordpress"
expect(page).to have_link count: 1 expect(page).to have_button count: 1
end end
end end
end end

View File

@@ -130,7 +130,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Register" click_link "Register"
click_link "Sign up with Twitter" click_button "Sign up with Twitter"
expect_to_be_signed_in expect_to_be_signed_in
@@ -149,7 +149,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Register" click_link "Register"
click_link "Sign up with Twitter" click_button "Sign up with Twitter"
expect(page).to have_current_path(new_user_session_path) expect(page).to have_current_path(new_user_session_path)
expect(page).to have_content "To continue, please click on the confirmation " \ expect(page).to have_content "To continue, please click on the confirmation " \
@@ -160,7 +160,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Sign in" click_link "Sign in"
click_link "Sign in with Twitter" click_button "Sign in with Twitter"
expect_to_be_signed_in expect_to_be_signed_in
within("#notice") { click_button "Close" } within("#notice") { click_button "Close" }
@@ -177,7 +177,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Register" click_link "Register"
click_link "Sign up with Twitter" click_button "Sign up with Twitter"
expect(page).to have_current_path(finish_signup_path) expect(page).to have_current_path(finish_signup_path)
fill_in "Email", with: "manueladelascarmenas@example.com" fill_in "Email", with: "manueladelascarmenas@example.com"
@@ -191,7 +191,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Sign in" click_link "Sign in"
click_link "Sign in with Twitter" click_button "Sign in with Twitter"
expect_to_be_signed_in expect_to_be_signed_in
within("#notice") { click_button "Close" } within("#notice") { click_button "Close" }
@@ -208,7 +208,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Register" click_link "Register"
click_link "Sign up with Twitter" click_button "Sign up with Twitter"
expect(page).to have_current_path(finish_signup_path) expect(page).to have_current_path(finish_signup_path)
click_link "Cancel login" click_link "Cancel login"
@@ -228,7 +228,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Sign in" click_link "Sign in"
click_link "Sign in with Twitter" click_button "Sign in with Twitter"
expect_to_be_signed_in expect_to_be_signed_in
@@ -247,7 +247,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Register" click_link "Register"
click_link "Sign up with Twitter" click_button "Sign up with Twitter"
expect(page).to have_current_path(finish_signup_path) expect(page).to have_current_path(finish_signup_path)
@@ -275,7 +275,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Register" click_link "Register"
click_link "Sign up with Twitter" click_button "Sign up with Twitter"
expect(page).to have_current_path(finish_signup_path) expect(page).to have_current_path(finish_signup_path)
expect(page).to have_field "Username", with: "manuela" expect(page).to have_field "Username", with: "manuela"
@@ -296,7 +296,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Sign in" click_link "Sign in"
click_link "Sign in with Twitter" click_button "Sign in with Twitter"
within("#notice") { click_button "Close" } within("#notice") { click_button "Close" }
click_link "My account" click_link "My account"
@@ -312,7 +312,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Register" click_link "Register"
click_link "Sign up with Twitter" click_button "Sign up with Twitter"
expect(page).to have_current_path(finish_signup_path) expect(page).to have_current_path(finish_signup_path)
@@ -332,7 +332,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Sign in" click_link "Sign in"
click_link "Sign in with Twitter" click_button "Sign in with Twitter"
expect_to_be_signed_in expect_to_be_signed_in
within("#notice") { click_button "Close" } within("#notice") { click_button "Close" }
@@ -350,7 +350,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Register" click_link "Register"
click_link "Sign up with Twitter" click_button "Sign up with Twitter"
expect(page).to have_current_path(finish_signup_path) expect(page).to have_current_path(finish_signup_path)
@@ -366,7 +366,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Sign in" click_link "Sign in"
click_link "Sign in with Twitter" click_button "Sign in with Twitter"
expect_to_be_signed_in expect_to_be_signed_in
within("#notice") { click_button "Close" } within("#notice") { click_button "Close" }
@@ -398,7 +398,7 @@ describe "Users" do
create(:user, username: "manuela", email: "manuelacarmena@example.com") create(:user, username: "manuela", email: "manuelacarmena@example.com")
visit new_user_session_path visit new_user_session_path
click_link "Sign in with Google" click_button "Sign in with Google"
expect_to_be_signed_in expect_to_be_signed_in
end end
@@ -423,7 +423,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Register" click_link "Register"
click_link "Sign up with Wordpress" click_button "Sign up with Wordpress"
expect(page).to have_current_path(new_user_session_path) expect(page).to have_current_path(new_user_session_path)
expect(page).to have_content "To continue, please click on the confirmation " \ expect(page).to have_content "To continue, please click on the confirmation " \
@@ -434,7 +434,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Sign in" click_link "Sign in"
click_link "Sign in with Wordpress" click_button "Sign in with Wordpress"
expect_to_be_signed_in expect_to_be_signed_in
within("#notice") { click_button "Close" } within("#notice") { click_button "Close" }
@@ -452,7 +452,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Register" click_link "Register"
click_link "Sign up with Wordpress" click_button "Sign up with Wordpress"
expect(page).to have_current_path(finish_signup_path) expect(page).to have_current_path(finish_signup_path)
@@ -475,7 +475,7 @@ describe "Users" do
visit "/" visit "/"
click_link "Sign in" click_link "Sign in"
click_link "Sign in with Wordpress" click_button "Sign in with Wordpress"
expect_to_be_signed_in expect_to_be_signed_in