Replace link with buttons in follow button

This commit is contained in:
cyrillefr
2025-04-14 10:40:25 +02:00
parent ddfd1bedb3
commit e370a52650
2 changed files with 23 additions and 23 deletions

View File

@@ -1,17 +1,17 @@
<div class="js-follow">
<span class="followable-content">
<% if follow.followable.followed_by?(current_user) %>
<%= link_to t("shared.following"),
<%= button_to t("shared.following"),
follow_path(follow),
method: :delete, remote: true,
title: unfollow_text(follow.followable),
class: "button expanded" %>
<% else %>
<%= link_to follow_text(follow.followable),
<%= button_to follow_text(follow.followable),
follows_path(followable_id: follow.followable.id,
followable_type: follow.followable.class.name),
method: :post, remote: true,
remote: true,
title: follow_text(follow.followable),
class: "button hollow expanded" %>
<% end %>

View File

@@ -17,7 +17,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
visit send(followable_path, arguments)
within "##{dom_id(followable)}" do
expect(page).not_to have_link("Follow")
expect(page).not_to have_button("Follow")
end
end
@@ -28,7 +28,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
visit send(followable_path, arguments)
within "##{dom_id(followable)}" do
expect(page).to have_link("Follow #{followable.model_name.human.downcase}")
expect(page).to have_button("Follow #{followable.model_name.human.downcase}")
end
end
@@ -37,7 +37,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
login_as(user)
visit send(followable_path, arguments)
expect(page).to have_link("Follow #{followable.model_name.human.downcase}")
expect(page).to have_button("Follow #{followable.model_name.human.downcase}")
end
scenario "Should display unfollow after user clicks on follow button" do
@@ -46,10 +46,10 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
visit send(followable_path, arguments)
within "##{dom_id(followable)}" do
click_link("Follow #{followable.model_name.human.downcase}")
click_button("Follow #{followable.model_name.human.downcase}")
expect(page).not_to have_link("Follow")
expect(page).to have_link("Following")
expect(page).not_to have_button("Follow")
expect(page).to have_button("Following")
end
end
@@ -59,7 +59,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
visit send(followable_path, arguments)
within "##{dom_id(followable)}" do
click_link("Follow #{followable.model_name.human.downcase}")
click_button("Follow #{followable.model_name.human.downcase}")
end
expect(page).to have_content "We will notify you of changes as they occur"
@@ -71,7 +71,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
visit send(followable_path, arguments)
expect(page).to have_link("Following")
expect(page).to have_button("Following")
end
scenario "Updates follow button & show destroy notice after unfollow button is clicked" do
@@ -80,10 +80,10 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
visit send(followable_path, arguments)
within "##{dom_id(followable)}" do
click_link("Unfollow #{followable.model_name.human.downcase}")
click_button("Unfollow #{followable.model_name.human.downcase}")
expect(page).not_to have_link("Unfollow")
expect(page).to have_link("Follow #{followable.model_name.human.downcase}")
expect(page).not_to have_button("Unfollow")
expect(page).to have_button("Follow #{followable.model_name.human.downcase}")
end
end
@@ -93,7 +93,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
visit send(followable_path, arguments)
within "##{dom_id(followable)}" do
click_link("Unfollow #{followable.model_name.human.downcase}")
click_button("Unfollow #{followable.model_name.human.downcase}")
end
expect(page).to have_content "You will no longer receive notifications"