summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-10-30 08:53:24 +0000
committerLin Jen-Shin <godfat@godfat.org>2017-10-30 18:16:09 +0800
commit8362a875728cd784a11d70460f82c14a2d3eca99 (patch)
tree60a56da674e94389b18d1465f9bb099644a045e5
parent39ec9bd4e635c3f6bc00a2dadd0359619a64236f (diff)
downloadgitlab-ce-8362a875728cd784a11d70460f82c14a2d3eca99.tar.gz
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
-rw-r--r--app/controllers/confirmations_controller.rb2
-rw-r--r--app/models/email.rb2
-rw-r--r--changelogs/unreleased/39366-email-confirmation-fails.yml5
-rw-r--r--spec/models/email_spec.rb8
4 files changed, 16 insertions, 1 deletions
diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb
index 80ab681ed87..bc0948cd3fb 100644
--- a/app/controllers/confirmations_controller.rb
+++ b/app/controllers/confirmations_controller.rb
@@ -10,7 +10,7 @@ class ConfirmationsController < Devise::ConfirmationsController
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)
diff --git a/app/models/email.rb b/app/models/email.rb
index 384f38f2db7..2da8b050149 100644
--- a/app/models/email.rb
+++ b/app/models/email.rb
@@ -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
diff --git a/changelogs/unreleased/39366-email-confirmation-fails.yml b/changelogs/unreleased/39366-email-confirmation-fails.yml
new file mode 100644
index 00000000000..a5568670c70
--- /dev/null
+++ b/changelogs/unreleased/39366-email-confirmation-fails.yml
@@ -0,0 +1,5 @@
+---
+title: 'Fix bug preventing secondary emails from being confirmed'
+merge_request: 15010
+author:
+type: fixed
diff --git a/spec/models/email_spec.rb b/spec/models/email_spec.rb
index b32dd31ae6d..47eb0717c0c 100644
--- a/spec/models/email_spec.rb
+++ b/spec/models/email_spec.rb
@@ -40,4 +40,12 @@ describe Email do
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