Commit f03700f5 authored by Douwe Maan's avatar Douwe Maan
Browse files

Merge branch '39366-email-confirmation-fails' into 'master'

grab the correct username when confirming secondary email

Closes #39366

See merge request gitlab-org/gitlab-ce!15010
......@@ -10,7 +10,7 @@ def after_resending_confirmation_instructions_path_for(resource)
users_almost_there_path
end
def after_confirmation_path_for(_resource_name, resource)
def after_confirmation_path_for(resource_name, resource)
# incoming resource can either be a :user or an :email
if signed_in?(:user)
after_sign_in(resource)
......
......@@ -14,6 +14,8 @@ class Email < ActiveRecord::Base
devise :confirmable
self.reconfirmable = false # currently email can't be changed, no need to reconfirm
delegate :username, to: :user
def email=(value)
write_attribute(:email, value.downcase.strip)
end
......
---
title: 'Fix bug preventing secondary emails from being confirmed'
merge_request: 15010
author:
type: fixed
......@@ -40,4 +40,12 @@
expect(user.emails.confirmed.count).to eq 1
end
end
describe 'delegation' do
let(:user) { create(:user) }
it 'delegates to :user' do
expect(build(:email, user: user).username).to eq user.username
end
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment