diff --git a/app/views/follows/_follow_button.html.erb b/app/views/follows/_follow_button.html.erb index 3b1305867..4713975e9 100644 --- a/app/views/follows/_follow_button.html.erb +++ b/app/views/follows/_follow_button.html.erb @@ -1,19 +1,19 @@
<% if follow.followable.followed_by?(current_user) %> - <%= link_to t("shared.following"), - follow_path(follow), - method: :delete, remote: true, - title: unfollow_text(follow.followable), - class: "button expanded" %> + <%= 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), - follows_path(followable_id: follow.followable.id, - followable_type: follow.followable.class.name), - method: :post, remote: true, - title: follow_text(follow.followable), - class: "button hollow expanded" %> + <%= button_to follow_text(follow.followable), + follows_path(followable_id: follow.followable.id, + followable_type: follow.followable.class.name), + remote: true, + title: follow_text(follow.followable), + class: "button hollow expanded" %> <% end %>
diff --git a/spec/shared/system/followable.rb b/spec/shared/system/followable.rb index 0d754d8e0..477626354 100644 --- a/spec/shared/system/followable.rb +++ b/spec/shared/system/followable.rb @@ -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"