diff --git a/app/views/users/_form_fields.html.erb b/app/views/users/_form_fields.html.erb index 105de457b..1a3e70988 100644 --- a/app/views/users/_form_fields.html.erb +++ b/app/views/users/_form_fields.html.erb @@ -1,13 +1,21 @@
- Name: <%= @user.name %> <%= link_to 'Change name'.html_safe, edit_user_name_path(@user) %> + Name: <%= @user.name %> + <%= link_to edit_user_name_path(@user) do %> + Change name + <% end %>
- Email: <%= @user.email %> <%= link_to 'Change email'.html_safe, edit_user_email_path(@user) %> + Email: <%= @user.email %> + <%= link_to edit_user_email_path(@user) do %> + Change email + <% end %>
<% if policy(User).assign_role? %> - <% if @user.reason_for_2sv_exemption.blank? %> + <% if @user.exempt_from_2sv? %> +This user's role is set to <%= @user.role %>. They are currently exempted from 2-step verification, meaning that their role cannot be changed as admins are required to have 2-step verification.
+ <% else %>
<%= f.label :role %>
<%= f.select :role, options_for_select(assignable_user_roles.map(&:humanize).zip(assignable_user_roles), f.object.role), {}, class: "chosen-select form-control", 'data-module' => 'chosen' %>
@@ -18,8 +26,6 @@
Organisation Admins can unlock and unsuspend their organisation accounts.
This user's role is set to <%= @user.role %>. They are currently exempted from 2-step verification, meaning that their role cannot be changed as admins are required to have 2-step verification.
<% end %> <% end %> diff --git a/app/views/users/emails/edit.html.erb b/app/views/users/emails/edit.html.erb index f1d8fbe67..a2e089b79 100644 --- a/app/views/users/emails/edit.html.erb +++ b/app/views/users/emails/edit.html.erb @@ -64,9 +64,12 @@ autocomplete: "off", error_items: @user.errors.full_messages_for(:email).map { |message| { text: message } } } %> - <%= render "govuk_publishing_components/components/button", { - text: "Change email" - } %> + <% end %> diff --git a/app/views/users/names/edit.html.erb b/app/views/users/names/edit.html.erb index f8618c935..acac9a7ed 100644 --- a/app/views/users/names/edit.html.erb +++ b/app/views/users/names/edit.html.erb @@ -51,9 +51,12 @@ autocomplete: "off", error_items: @user.errors.full_messages_for(:name).map { |message| { text: message } } } %> - <%= render "govuk_publishing_components/components/button", { - text: "Change name" - } %> + <% end %> diff --git a/test/controllers/users/emails_controller_test.rb b/test/controllers/users/emails_controller_test.rb index 4e5c7aa38..6c915d81e 100644 --- a/test/controllers/users/emails_controller_test.rb +++ b/test/controllers/users/emails_controller_test.rb @@ -19,6 +19,8 @@ class Users::EmailsControllerTest < ActionController::TestCase assert_template :edit assert_select "form[action='#{user_email_path(user)}']" do assert_select "input[name='user[email]']", value: "user@gov.uk" + assert_select "button[type='submit']", text: "Change email" + assert_select "a[href='#{edit_user_path(user)}']", text: "Cancel" end end diff --git a/test/controllers/users/names_controller_test.rb b/test/controllers/users/names_controller_test.rb index c42c840d3..d06110ba9 100644 --- a/test/controllers/users/names_controller_test.rb +++ b/test/controllers/users/names_controller_test.rb @@ -16,6 +16,8 @@ class Users::NamesControllerTest < ActionController::TestCase assert_template :edit assert_select "form[action='#{user_name_path(user)}']" do assert_select "input[name='user[name]']", value: "user-name" + assert_select "button[type='submit']", text: "Change name" + assert_select "a[href='#{edit_user_path(user)}']", text: "Cancel" end end diff --git a/test/integration/change_user_role_test.rb b/test/integration/change_user_role_test.rb index d0b015897..faf1ba1e9 100644 --- a/test/integration/change_user_role_test.rb +++ b/test/integration/change_user_role_test.rb @@ -13,7 +13,7 @@ def sign_in_as_and_edit_user(sign_in_as, user_to_edit) end context "when logged in as a super admin" do - should "be able to change the role of a user who has no 2SV exemption reason" do + should "be able to change the role of a user who is not exempt from 2SV" do user = create(:user) sign_in_as_and_edit_user(@super_admin, user) @@ -23,7 +23,7 @@ def sign_in_as_and_edit_user(sign_in_as, user_to_edit) assert user.reload.admin? end - should "not be able to change the role of a user who has a 2SV exemption reason" do + should "not be able to change the role of a user who is exempt from 2SV" do user = create(:two_step_exempted_user) sign_in_as_and_edit_user(@super_admin, user)