summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Reigel <mail@koffeinfrei.org>2017-08-28 12:27:18 +0200
committerAlexis Reigel <mail@koffeinfrei.org>2017-09-05 12:18:32 +0200
commit98016ef7f395303682f472414b2f109ff8a598f5 (patch)
treef207b3b0d8ca9b58b1c5154ed0ae46f1288cce34
parent3b090bb9a9d857f8db1a8b16a48d39afdb02a21b (diff)
downloadgitlab-ce-98016ef7f395303682f472414b2f109ff8a598f5.tar.gz
add User##verified_email? method
-rw-r--r--app/models/user.rb4
-rw-r--r--spec/models/user_spec.rb14
2 files changed, 18 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 9d48c82e861..c5b5f09722f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1041,6 +1041,10 @@ class User < ActiveRecord::Base
ensure_rss_token!
end
+ def verified_email?(email)
+ self.email == email
+ end
+
protected
# override, from Devise::Validatable
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index b70ab5581ac..fd83a58ed9f 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -2102,4 +2102,18 @@ describe User do
end
end
end
+
+ describe '#verified_email?' do
+ it 'returns true when the email is the primary email' do
+ user = build :user, email: 'email@example.com'
+
+ expect(user.verified_email?('email@example.com')).to be true
+ end
+
+ it 'returns false when the email is not the primary email' do
+ user = build :user, email: 'email@example.com'
+
+ expect(user.verified_email?('other_email@example.com')).to be false
+ end
+ end
end