Browse Source

more tests and tweaks

pull/787/head
JG 3 years ago
parent
commit
4109e5908b
  1. 4
      app/controllers/users_controller.rb
  2. 4
      app/views/users/show.html.erb
  3. 3
      config/routes.rb
  4. 22
      spec/features/user_spec.rb

4
app/controllers/users_controller.rb

@ -30,6 +30,10 @@ class UsersController < ApplicationController
def show; end
def dpo; end
def key_contact; end
def edit
redirect_to user_path(@user) unless @user.active?
end

4
app/views/users/show.html.erb

@ -81,7 +81,7 @@
if can_edit_dpo?(@user, current_user)
row.action(
visually_hidden_text: "if data protection officer",
href: aliased_user_edit(@user, current_user),
href: user_edit_dpo_path(@user),
html_attributes: { "data-qa": "change-data-protection-officer" },
)
else
@ -95,7 +95,7 @@
if can_edit_key_contact?(@user, current_user)
row.action(
visually_hidden_text: "if a key contact",
href: aliased_user_edit(@user, current_user),
href: user_edit_key_contact_path(@user),
html_attributes: { "data-qa": "change-key-contact" },
)
else

3
config/routes.rb

@ -53,6 +53,9 @@ Rails.application.routes.draw do
end
resources :users do
get "edit_dpo", to: "users#dpo"
get "edit_key_contact", to: "users#key_contact"
member do
get "deactivate", to: "users#deactivate"
get "reactivate", to: "users#reactivate"

22
spec/features/user_spec.rb

@ -363,6 +363,28 @@ RSpec.describe "User Features" do
role: "data_provider",
)).to be_a(User)
end
context "when updating other user DPO and key contact information" do
it "allows updating users dpo details" do
visit("/organisations/#{user.organisation.id}")
click_link("Users")
click_link(other_user.name)
find("a[href='#{user_edit_dpo_path(other_user)}']").click
choose("Yes")
click_button("Save changes")
expect(User.find_by(name: "Other name", role: "data_provider", is_dpo: true)).to be_a(User)
end
it "allows updating users key contact details" do
visit("/organisations/#{user.organisation.id}")
click_link("Users")
click_link(other_user.name)
find("a[href='#{user_edit_key_contact_path(other_user)}']").click
choose("Yes")
click_button("Save changes")
expect(User.find_by(name: "Other name", role: "data_provider", is_key_contact: true)).to be_a(User)
end
end
end
context "when deactivating a user" do

Loading…
Cancel
Save