From aebf867aeee6fd6b9c4f7766b412133cdecd177d Mon Sep 17 00:00:00 2001 From: Brandon Labuschagne Date: Fri, 14 Jun 2019 13:53:12 +0200 Subject: [PATCH] Add verification badge to users emails This is being applied to the admin users view, when an admin selects a user profile tp view. It gives admins the ability to see an email verification status without the need of impersonating a user. --- app/views/admin/users/show.html.haml | 5 ++-- ...min-area-if-emails-are-verified-or-not.yml | 5 ++++ spec/features/admin/admin_users_spec.rb | 26 +++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/49814-display-in-admin-area-if-emails-are-verified-or-not.yml diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index dcd6f7c8078..5c6131db37d 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -32,11 +32,12 @@ %li %span.light Email: %strong - = mail_to @user.email + = render partial: 'shared/email_with_badge', locals: { email: mail_to(@user.email), verified: @user.confirmed? } - @user.emails.each do |email| %li %span.light Secondary email: - %strong= email.email + %strong + = render partial: 'shared/email_with_badge', locals: { email: email.email, verified: email.confirmed? } = link_to remove_email_admin_user_path(@user, email), data: { confirm: "Are you sure you want to remove #{email.email}?" }, method: :delete, class: "btn-sm btn btn-remove float-right", title: 'Remove secondary email', id: "remove_email_#{email.id}" do %i.fa.fa-times %li diff --git a/changelogs/unreleased/49814-display-in-admin-area-if-emails-are-verified-or-not.yml b/changelogs/unreleased/49814-display-in-admin-area-if-emails-are-verified-or-not.yml new file mode 100644 index 00000000000..db1391edd73 --- /dev/null +++ b/changelogs/unreleased/49814-display-in-admin-area-if-emails-are-verified-or-not.yml @@ -0,0 +1,5 @@ +--- +title: Add a verified pill next to email addresses under the admin users section. +merge_request: 29669 +author: +type: added diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index 29545779a34..dafec29dfcc 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -419,6 +419,32 @@ describe "Admin::Users" do end end end + + describe 'Email verification status' do + let!(:secondary_email) do + create :email, email: 'secondary@example.com', user: user + end + + it 'displays the correct status for an unverified email address' do + user.update(confirmed_at: nil, unconfirmed_email: user.email) + visit admin_user_path(user) + + expect(page).to have_content("#{user.email} Unverified") + + expect(page).to have_content("#{secondary_email.email} Unverified") + end + + it 'displays the correct status for a verified email address' do + visit admin_user_path(user) + expect(page).to have_content("#{user.email} Verified") + + secondary_email.confirm + expect(secondary_email.confirmed?).to be_truthy + + visit admin_user_path(user) + expect(page).to have_content("#{secondary_email.email} Verified") + end + end end describe "GET /admin/users/:id/edit" do