Skip to content

Commit

Permalink
Use User#exempt_from_2sv? in user form fields partial
Browse files Browse the repository at this point in the history
This method is more intention-revealing than calling `Object#blank?` on
the return value from `User#reason_for_2sv_exemption`.
  • Loading branch information
floehopper committed Nov 20, 2023
1 parent 4a71291 commit f82b289
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/views/users/_form_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</p>

<% if policy(User).assign_role? %>
<% if @user.reason_for_2sv_exemption.blank? %>
<% if !@user.exempt_from_2sv? %>
<p class="form-group">
<%= f.label :role %><br />
<%= 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' %>
Expand Down
4 changes: 2 additions & 2 deletions test/integration/change_user_role_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit f82b289

Please sign in to comment.