diff --git a/app/decorators/user_decorator.rb b/app/decorators/user_decorator.rb index a4234c9937..132b3bf058 100644 --- a/app/decorators/user_decorator.rb +++ b/app/decorators/user_decorator.rb @@ -56,4 +56,8 @@ def formatted_date_of_birth object.date_of_birth.to_date.to_fs(:slashes) end + + def email_confirmation_status + object.confirmed? ? "Confirmed" : "Not confirmed" + end end diff --git a/app/views/users/_edit_profile.erb b/app/views/users/_edit_profile.erb index 900bd46e81..48e4f75fdf 100644 --- a/app/views/users/_edit_profile.erb +++ b/app/views/users/_edit_profile.erb @@ -10,6 +10,16 @@ Email <%= resource&.email %> +
+ Email confirmation status + <%= resource&.decorate&.email_confirmation_status %> +
+<% if resource&.unconfirmed_email.present? %> +
+ Pending email confirmation + <%= resource.unconfirmed_email %> +
+<% end %>
Invitation email sent <%= resource&.decorate(context: {format: :edit_profile})&.formatted_invitation_sent_at || "never" %> diff --git a/spec/decorators/user_decorator_spec.rb b/spec/decorators/user_decorator_spec.rb index 262a110130..67c6f39130 100644 --- a/spec/decorators/user_decorator_spec.rb +++ b/spec/decorators/user_decorator_spec.rb @@ -151,4 +151,20 @@ expect(decorated_user.formatted_date_of_birth).to eq "1991/07/08" end end + + describe "#email_confirmation_status" do + context "when the user's email is confirmed" do + it "returns Confirmed" do + user.update!(confirmed_at: Time.current) + expect(decorated_user.email_confirmation_status).to eq "Confirmed" + end + end + + context "when the user's email is not confirmed" do + it "returns Not confirmed" do + user.update_column(:confirmed_at, nil) + expect(decorated_user.email_confirmation_status).to eq "Not confirmed" + end + end + end end diff --git a/spec/system/users/edit_spec.rb b/spec/system/users/edit_spec.rb index 38e4f8a443..1763fa71c5 100644 --- a/spec/system/users/edit_spec.rb +++ b/spec/system/users/edit_spec.rb @@ -213,6 +213,27 @@ uncheck "user_receive_sms_notifications" expect(page).to have_field("toggle-sms-notification-event", type: "checkbox", disabled: true) end + + it "displays the email confirmation status" do + volunteer = create(:volunteer) + + sign_in volunteer + visit edit_users_path + + expect(page).to have_text("Email confirmation status") + expect(page).to have_text("Confirmed") + end + + it "displays a pending email change awaiting confirmation" do + volunteer = create(:volunteer) + volunteer.update(email: "new-email@example.com") + + sign_in volunteer + visit edit_users_path + + expect(page).to have_text("Pending email confirmation") + expect(page).to have_text("new-email@example.com") + end end context "when a user's casa organization does not have twilio enabled" do