summaryrefslogtreecommitdiff
path: root/app/models/email.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-04-02 21:02:02 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-04-02 21:02:02 +0300
commit599344583bcf57eff46b36d68e6536188d41c906 (patch)
treec3b8e0226688d4d1c22fdb159b57417386b7c74f /app/models/email.rb
parent3faa14e7a748097528ed36cf02ccacd62cd8f044 (diff)
downloadgitlab-ce-599344583bcf57eff46b36d68e6536188d41c906.tar.gz
Remove EmailsObserver
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/email.rb')
-rw-r--r--app/models/email.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/models/email.rb b/app/models/email.rb
index 22e71e4f107..b92c1841063 100644
--- a/app/models/email.rb
+++ b/app/models/email.rb
@@ -13,14 +13,15 @@ class Email < ActiveRecord::Base
# Relations
#
belongs_to :user
-
+
#
# Validations
#
validates :user_id, presence: true
validates :email, presence: true, email: { strict_mode: true }, uniqueness: true
validate :unique_email, if: ->(email) { email.email_changed? }
-
+
+ after_create :notify
before_validation :cleanup_email
def cleanup_email
@@ -30,4 +31,8 @@ class Email < ActiveRecord::Base
def unique_email
self.errors.add(:email, 'has already been taken') if User.exists?(email: self.email)
end
-end \ No newline at end of file
+
+ def notify
+ NotificationService.new.new_email(self)
+ end
+end