From 2c6207135e917a0b8f25f657916060405f1f85b5 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Thu, 31 Mar 2016 19:59:19 +0200 Subject: [PATCH] Allow temp-oauth-email as notification email --- CHANGELOG | 1 + app/models/user.rb | 2 ++ spec/models/user_spec.rb | 7 +++++++ 3 files changed, 10 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index f95a243b0a1..781843469f0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ v 8.7.0 (unreleased) v 8.6.3 (unreleased) - Destroy related todos when an Issue/MR is deleted. !3376 - Fix error 500 when target is nil on todo list. !3376 + - Allow temporary email as notification email. !TBD v 8.6.2 - Fix dropdown alignment. !3298 diff --git a/app/models/user.rb b/app/models/user.rb index 128ddc2a694..2b0bee2099f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -408,6 +408,8 @@ class User < ActiveRecord::Base end def owns_notification_email + return if self.temp_oauth_email? + self.errors.add(:notification_email, "is not an email you own") unless self.all_emails.include?(self.notification_email) end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 0ab7fd88ce6..8b2fb77e28e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -173,6 +173,13 @@ describe User, models: true do expect(user).to be_invalid end end + + context 'owns_notification_email' do + it 'accepts temp_oauth_email emails' do + user = build(:user, email: "temp-email-for-oauth@example.com") + expect(user).to be_valid + end + end end end