From 0621b26aec8f6fe44cee1939f7ce52a1eb6cf526 Mon Sep 17 00:00:00 2001 From: Aaron Spencer Date: Tue, 13 Jun 2023 15:45:32 +0100 Subject: [PATCH] CLDC-2328: Button uses post instead of get, tests reflect this. --- config/routes.rb | 2 +- spec/requests/users_controller_spec.rb | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index a4dc43134..5ddfcf25a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -103,7 +103,7 @@ Rails.application.routes.draw do member do get "deactivate", to: "users#deactivate" get "reactivate", to: "users#reactivate" - get "resend-invite", to: "users#resend_invite" + post "resend-invite", to: "users#resend_invite" end end diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb index 0a141f6fe..c20449bab 100644 --- a/spec/requests/users_controller_spec.rb +++ b/spec/requests/users_controller_spec.rb @@ -99,8 +99,8 @@ RSpec.describe UsersController, type: :request do describe "#resend_invite" do it "does not allow resending activation emails" do - get "/users/#{user.id}/deactivate", headers: headers, params: {} - expect(response).to redirect_to("/account/sign-in") + get deactivate_user_path(user.id), headers: headers, params: {} + expect(response).to redirect_to(new_user_session_path) end end end @@ -131,7 +131,7 @@ RSpec.describe UsersController, type: :request do end it "does not allow resending invitation emails" do - expect(page).not_to have_link("Resend invite link", href: "/users/#{other_user.id}/resend-invite") + expect(page).not_to have_button("Resend invite link") end context "when user is deactivated" do @@ -201,7 +201,7 @@ RSpec.describe UsersController, type: :request do end it "does not allow resending invitation emails" do - expect(page).not_to have_link("Resend invite link", href: "/users/#{other_user.id}/resend-invite") + expect(page).not_to have_button("Resend invite link") end end end @@ -520,7 +520,7 @@ RSpec.describe UsersController, type: :request do end it "does not allow resending invitation emails" do - expect(page).not_to have_link("Resend invite link", href: "/users/#{other_user.id}/resend-invite") + expect(page).not_to have_button("Resend invite link") end end end @@ -553,8 +553,8 @@ RSpec.describe UsersController, type: :request do expect(page).to have_link("Deactivate user", href: "/users/#{other_user.id}/deactivate") end - it "allows you to resend invitation emails" do - expect(page).to have_link("Resend invite link", href: "/users/#{other_user.id}/resend-invite") + it "does not allow you to resend invitation emails" do + expect(page).not_to have_button("Resend invite link") end context "when user is deactivated" do @@ -572,7 +572,7 @@ RSpec.describe UsersController, type: :request do end it "does not allow you to resend invitation emails" do - expect(page).not_to have_link("Resend invite link", href: "/users/#{other_user.id}/resend-invite") + expect(page).not_to have_button("Resend invite link") end end end @@ -1204,6 +1204,10 @@ RSpec.describe UsersController, type: :request do expect(page).to have_link("Deactivate user", href: "/users/#{other_user.id}/deactivate") end + it "allows you to resend invitation emails" do + expect(page).to have_button("Resend invite link") + end + context "when user is deactivated" do before do other_user.update!(active: false)