diff --git a/app/controllers/account/members_controller.rb b/app/controllers/account/members_controller.rb
index 707a0d235..be7d91e6d 100644
--- a/app/controllers/account/members_controller.rb
+++ b/app/controllers/account/members_controller.rb
@@ -10,6 +10,10 @@ def edit
def update
respond_to do |format|
if current_member.update(member_params)
+ if current_member.saved_change_to_email?
+ current_member.user.send_confirmation_instructions
+ end
+
format.html { redirect_to account_member_url, success: "Profile was successfully updated.", status: :see_other }
format.json { render :show, status: :ok, location: current_member }
else
diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb
index 98e45a29d..a7b8d468b 100644
--- a/app/mailers/user_mailer.rb
+++ b/app/mailers/user_mailer.rb
@@ -5,7 +5,7 @@ class UserMailer < Devise::Mailer
def store_notification
Notification.create!(
action: action_name,
- address: @user.email,
+ address: mail.to.join(","),
member: @user.member,
subject: mail.subject,
uuid: SecureRandom.uuid
diff --git a/app/views/admin/members/_profile.html.erb b/app/views/admin/members/_profile.html.erb
index a75e6f28c..f22582adb 100644
--- a/app/views/admin/members/_profile.html.erb
+++ b/app/views/admin/members/_profile.html.erb
@@ -27,7 +27,7 @@
Member's email address has not been verified.
- <%= link_to "Resend Verification Email", resend_verification_email_admin_member_path(@member), data: {turbo_method: "post", turbo_confirm: "Resend verification email to #{@member.user.email}?"} %>
+ <%= link_to "Resend Verification Email", resend_verification_email_admin_member_path(@member), data: {turbo_method: "post", turbo_confirm: "Resend verification email to #{@member.user.unconfirmed_email}?"} %>
<% end %>
diff --git a/app/views/admin/members/notifications/index.html.erb b/app/views/admin/members/notifications/index.html.erb
index 632d55160..2f9eaad89 100644
--- a/app/views/admin/members/notifications/index.html.erb
+++ b/app/views/admin/members/notifications/index.html.erb
@@ -6,6 +6,7 @@
Sent at |
Summary |
+ To |
@@ -14,6 +15,7 @@
<%= date_with_time_title notification.created_at %> |
<%= notification.subject %> |
+ <%= notification.address %> |
<% end %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index a325bbf74..9732b8384 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -36,6 +36,7 @@
<% end %>
+ <%= flash_message :notice %>
<%= flash_message :success %>
<%= flash_message :warning %>
<%= flash_message :error %>
diff --git a/test/controllers/account/appointments_controller_test.rb b/test/controllers/account/appointments_controller_test.rb
index 96f6ebd22..9a1fa45a0 100644
--- a/test/controllers/account/appointments_controller_test.rb
+++ b/test/controllers/account/appointments_controller_test.rb
@@ -20,15 +20,6 @@ class AppointmentsControllerTest < ActionDispatch::IntegrationTest
@appointment.save
end
- private def assert_enqueued_email(mailer, method, params: {})
- assert_enqueued_with(job: ActionMailer::MailDeliveryJob, args: ->(job_arguments) {
- job_mailer, job_method, _delivery, rest = *job_arguments
- assert_equal mailer.to_s, job_mailer
- assert_equal method.to_s, job_method
- assert_equal(params, rest[:params])
- })
- end
-
test "creates a new appointment to pickup items on hold" do
@hold = FactoryBot.create(:started_hold, member: @member)
@event = FactoryBot.create(:appointment_slot_event)
diff --git a/test/controllers/account/members_controller_test.rb b/test/controllers/account/members_controller_test.rb
index 36d0f0fdf..a666f8911 100644
--- a/test/controllers/account/members_controller_test.rb
+++ b/test/controllers/account/members_controller_test.rb
@@ -32,6 +32,16 @@ class MembersControllerTest < ActionDispatch::IntegrationTest
assert_equal "Updated Name", @member.full_name
end
+ test "member updates email" do
+ patch account_member_url, params: {member: {email: "new.email@example.com"}}
+
+ sent_email = ActionMailer::Base.deliveries.first
+ assert_equal ["new.email@example.com"], sent_email.to
+ assert_equal "Confirmation instructions", sent_email.subject
+
+ assert_redirected_to account_member_url
+ end
+
test "member update redirects to edit when provided invalid params" do
patch account_member_url, params: {member: {full_name: nil}}
assert_template :edit
diff --git a/test/mailers/user_mailer_test.rb b/test/mailers/user_mailer_test.rb
index 22d4358ec..6644dac5f 100644
--- a/test/mailers/user_mailer_test.rb
+++ b/test/mailers/user_mailer_test.rb
@@ -41,5 +41,7 @@ class UserMailerTest < ActionMailer::TestCase
actions = Notification.pluck(:action)
assert_includes actions, "reset_password_instructions"
assert_includes actions, "email_changed"
+
+ assert_equal [user.email, user.email], Notification.pluck(:address)
end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 4108a3e30..4989c3c2a 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -41,6 +41,14 @@ def assert_size(expected, subject)
end
class ActionDispatch::IntegrationTest
- # @note Just to make tests pass for now...
include EnsureRequestTenant
+
+ def assert_enqueued_email(mailer, method, params: {})
+ assert_enqueued_with(job: ActionMailer::MailDeliveryJob, args: ->(job_arguments) {
+ job_mailer, job_method, _delivery, rest = *job_arguments
+ assert_equal mailer.to_s, job_mailer
+ assert_equal method.to_s, job_method
+ assert_equal(params, rest[:params])
+ })
+ end
end