diff --git a/app/models/email.rb b/app/models/email.rb index d6516761f0af655e832eb4e2457dbbc6275a9b33..15bdedeac33dc3f5c6d0c3da49be34fb81f93125 100644 --- a/app/models/email.rb +++ b/app/models/email.rb @@ -25,6 +25,10 @@ class Email < ActiveRecord::Base self.errors.add(:email, 'has already been taken') if User.exists?(email: self.email) end + def accept_pending_invitations! + user.accept_pending_invitations! + end + # once email is confirmed, update the gpg signatures def update_invalid_gpg_signatures user.update_invalid_gpg_signatures if confirmed? diff --git a/changelogs/unreleased/fix-email-confirmation-addtional-email.yml b/changelogs/unreleased/fix-email-confirmation-addtional-email.yml new file mode 100644 index 0000000000000000000000000000000000000000..56a2efa4d60775940ddac36cda7b169317ce822c --- /dev/null +++ b/changelogs/unreleased/fix-email-confirmation-addtional-email.yml @@ -0,0 +1,5 @@ +--- +title: Fix email confirmation bug when user adds additional email to account +merge_request: 20084 +author: muhammadn +type: fixed diff --git a/spec/features/users/add_email_to_existing_account.rb b/spec/features/users/add_email_to_existing_account.rb new file mode 100644 index 0000000000000000000000000000000000000000..4355f769429439ea524c4df403e788f13db9a663 --- /dev/null +++ b/spec/features/users/add_email_to_existing_account.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe 'AdditionalEmailToExistingAccount' do + describe 'add secondary email associated with account' do + let(:user) { create(:user) } + + it 'verifies confirmation of additional email' do + sign_in(user) + + email = create(:email, user: user) + visit email_confirmation_path(confirmation_token: email.confirmation_token) + expect(page).to have_content 'Your email address has been successfully confirmed.' + end + end +end