diff --git a/app/helpers/api_users_helper.rb b/app/helpers/api_users_helper.rb
index 65d3d78f4..b9884efd7 100644
--- a/app/helpers/api_users_helper.rb
+++ b/app/helpers/api_users_helper.rb
@@ -4,8 +4,7 @@ def truncate_access_token(token)
end
def api_user_name(user)
- anchor_tag = link_to(user.name, edit_api_user_path(user), class: "govuk-link")
- user.suspended? ? content_tag(:del, anchor_tag) : anchor_tag
+ link_to(user.name, edit_api_user_path(user), class: "govuk-link")
end
def application_list(user)
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index fe9e36719..8f2fc8d0c 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -5,6 +5,16 @@ def status(user)
user.status.humanize
end
+ def status_with_tag(user)
+ css_classes = if user.status == User::USER_STATUS_ACTIVE
+ "govuk-tag--green"
+ else
+ "govuk-tag--grey"
+ end
+
+ govuk_tag(status(user), css_classes)
+ end
+
def two_step_status(user)
user.two_step_status.humanize.capitalize
end
@@ -63,8 +73,7 @@ def filtered_users_heading(users)
end
def user_name(user)
- anchor_tag = link_to(user.name, edit_user_path(user), class: "govuk-link")
- user.suspended? ? content_tag(:del, anchor_tag) : anchor_tag
+ link_to(user.name, edit_user_path(user), class: "govuk-link")
end
def options_for_role_select(selected: nil)
diff --git a/app/views/api_users/index.html.erb b/app/views/api_users/index.html.erb
index 4070766db..af04541d5 100644
--- a/app/views/api_users/index.html.erb
+++ b/app/views/api_users/index.html.erb
@@ -24,7 +24,7 @@
text: "Apps",
},
{
- text: "Suspended?",
+ text: "Status",
},
],
rows: @api_users.map do |user|
@@ -39,7 +39,7 @@
text: application_list(user),
},
{
- text: user.suspended? ? "Yes" : "No",
+ text: status_with_tag(user),
},
]
end,
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
index 178c653d6..dc33cf595 100644
--- a/app/views/users/index.html.erb
+++ b/app/views/users/index.html.erb
@@ -40,7 +40,7 @@
{ text: user_name(user) },
{ text: user.email },
{ text: user.role_display_name },
- { text: status(user) },
+ { text: status_with_tag(user) },
{ text: two_step_status(user) },
]
end,
diff --git a/test/helpers/users_helper_test.rb b/test/helpers/users_helper_test.rb
index 46b7b7de4..3afe0c739 100644
--- a/test/helpers/users_helper_test.rb
+++ b/test/helpers/users_helper_test.rb
@@ -1,6 +1,8 @@
require "test_helper"
class UsersHelperTest < ActionView::TestCase
+ include ApplicationHelper
+
test "sync_needed? should work with user permissions not synced yet" do
application = create(:application)
user = create(:user)
@@ -16,6 +18,13 @@ class UsersHelperTest < ActionView::TestCase
assert_equal "Suspended", status(build(:suspended_user))
end
+ test "status_with_tag should enclose the status in a govuk tag" do
+ assert_equal "Invited", status_with_tag(build(:invited_user))
+ assert_equal "Active", status_with_tag(build(:active_user))
+ assert_equal "Locked", status_with_tag(build(:locked_user))
+ assert_equal "Suspended", status_with_tag(build(:suspended_user))
+ end
+
test "two_step_status should reflect the user's status accurately when the user is exempted from 2sv" do
assert_equal "Exempted", two_step_status(create(:two_step_exempted_user))
assert_equal "Exempted", two_step_status_with_requirement(create(:two_step_exempted_user))
diff --git a/test/integration/manage_api_users_test.rb b/test/integration/manage_api_users_test.rb
index 3a60478fb..f468c21fc 100644
--- a/test/integration/manage_api_users_test.rb
+++ b/test/integration/manage_api_users_test.rb
@@ -20,7 +20,7 @@ class ManageApiUsersTest < ActionDispatch::IntegrationTest
assert page.has_selector?("td", text: @api_user.email)
assert page.has_selector?("td", text: @application.name)
- assert page.has_selector?("td:last-child", text: "No") # suspended?
+ assert page.has_selector?("td:last-child", text: "Active") # status
end
should "be able to create and edit an API user" do