From 47c0538449e82f6d96ddc3af9e15367415ce959b Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 30 May 2022 09:31:18 +0100 Subject: [PATCH] Show reactivate user link for deactivated users --- app/views/users/show.html.erb | 2 +- spec/requests/users_controller_spec.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 8607f4f1d..0166f28cd 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -9,7 +9,7 @@ <% if @user.active? %> <%= govuk_link_to "Deactivate user", "/users/#{@user.id}/deactivate" %> <% else %> - This user has been deactivated. + This user has been deactivated. <%= govuk_link_to "Reactivate user", "/users/#{@user.id}/reactivate" %> <% end %> <% end %> diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb index 8e6e44385..82f69eb0f 100644 --- a/spec/requests/users_controller_spec.rb +++ b/spec/requests/users_controller_spec.rb @@ -515,6 +515,10 @@ RSpec.describe UsersController, type: :request do it "shows if user is not active" do expect(page).to have_content("This user has been deactivated.") end + + it "allows reactivating the user" do + expect(page).to have_link("Reactivate user", href: "/users/#{other_user.id}/reactivate") + end end end @@ -1086,6 +1090,21 @@ RSpec.describe UsersController, type: :request do it "allows deactivating the user" do expect(page).to have_link("Deactivate user", href: "/users/#{other_user.id}/deactivate") end + + context "when user is deactivated" do + before do + other_user.update!(active: false) + get "/users/#{other_user.id}", headers:, params: {} + end + + it "shows if user is not active" do + expect(page).to have_content("This user has been deactivated.") + end + + it "allows reactivating the user" do + expect(page).to have_link("Reactivate user", href: "/users/#{other_user.id}/reactivate") + end + end end context "when the user is not part of the same organisation as the current user" do