Permalink
Browse files

[DEPRECATION] Notifier is deprecated, use DeviseMailer instead. Remem…

…ber to rename app/views/notifier to app/views/devise_mailer and I18n key from devise.notifier to devise.mailer.
  • Loading branch information...
1 parent e7f809d commit dc86a571aeb13dbe6068346c21abc08e57435b96 @josevalim josevalim committed Nov 3, 2009
View
@@ -1,9 +1,12 @@
-* enhancement
- * [#16] Allow devise to be more agnostic. Do not require ActiveRecord to be loaded.
-
* deprecations
+ * Notifier is deprecated, use DeviseMailer instead. Remember to rename
+ app/views/notifier to app/views/devise_mailer and I18n key from
+ devise.notifier to devise.mailer
* Model configuration is on Devise::Models.config and not on Devise.config anymore.
+* enhancement
+ * [#16] Allow devise to be more agnostic. Do not require ActiveRecord to be loaded.
+
== 0.3.0
* bug fix
View
@@ -182,7 +182,7 @@ After signing in a user, confirming it's account or updating it's password, devi
You also need to setup default url options for the mailer, if you are using confirmable or recoverable. Here's is the configuration for development:
- Notifier.sender = "no-reply@yourapp.com"
+ DeviseMailer.sender = "no-reply@yourapp.com"
ActionMailer::Base.default_url_options = { :host => 'localhost:3000' }
== Tidying up
@@ -220,7 +220,7 @@ You can also copy devise views to your application, being able to modify them ba
script/generate devise_views
-This is gonna copy all session, password, confirmation and notifier views to your app/views folder.
+This is gonna copy all session, password, confirmation and mailer views to your app/views folder.
== I18n
@@ -241,11 +241,11 @@ You can also create distinct messages based on the resource you've configured us
admin:
signed_in: 'Hello admin!'
-Devise notifier uses the same pattern to create subject messages:
+Devise mailer uses the same pattern to create subject messages:
en:
devise:
- notifier:
+ mailer:
confirmation_instructions: 'Hello everybody!'
user:
confirmation_instructions: 'Hello User! Please confirm your email'
@@ -1,5 +1,15 @@
-class Notifier < ::ActionMailer::Base
- cattr_accessor :sender
+class DeviseMailer < ::ActionMailer::Base
+
+ # Sets who is sending the e-mail
+ def self.sender=(value)
+ @@sender = value
+ end
+
+ # Reads who is sending the e-mail
+ def self.sender
+ @@sender
+ end
+ self.sender = nil
# Deliver confirmation instructions when the user is created or its email is
# updated, and also when confirmation is manually requested
@@ -33,12 +43,11 @@ def setup_mail(record, key)
#
# en:
# devise:
- # notifier:
+ # mailer:
# confirmation_instructions: '...'
# user:
- # notifier:
- # confirmation_instructions: '...'
+ # confirmation_instructions: '...'
def translate(mapping, key)
- I18n.t(:"#{mapping.name}.#{key}", :scope => [:devise, :notifier], :default => key)
+ I18n.t(:"#{mapping.name}.#{key}", :scope => [:devise, :mailer], :default => key)
end
end
@@ -12,7 +12,7 @@ en:
confirmations:
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
confirmed: 'Your account was successfully confirmed. You are now signed in.'
- notifier:
+ mailer:
confirmation_instructions: 'Confirmation instructions'
reset_password_instructions: 'Reset password instructions'
@@ -56,7 +56,7 @@ def confirmed?
# Send confirmation instructions by email
def send_confirmation_instructions
- ::Notifier.deliver_confirmation_instructions(self)
+ ::DeviseMailer.deliver_confirmation_instructions(self)
end
# Remove confirmation date and send confirmation instructions, to ensure
@@ -101,7 +101,7 @@ def active?
#
def confirmation_period_valid?
confirmation_sent_at? &&
- (Date.today - confirmation_sent_at.to_date).days < confirm_within
+ (Time.now.utc - confirmation_sent_at.utc) < confirm_within
end
# Checks whether the record is confirmed or not, yielding to the block
@@ -35,7 +35,7 @@ def reset_password!(new_password, new_password_confirmation)
# Resets reset password token and send reset password instructions by email
def send_reset_password_instructions
generate_reset_password_token!
- ::Notifier.deliver_reset_password_instructions(self)
+ ::DeviseMailer.deliver_reset_password_instructions(self)
end
protected
@@ -45,7 +45,7 @@ def self.included(base)
# Generate a new remember token and save the record without validations.
def remember_me!
self.remember_token = friendly_token
- self.remember_created_at = Time.now
+ self.remember_created_at = Time.now.utc
save(false)
end
@@ -66,7 +66,7 @@ def valid_remember_token?(token)
# Remember token should be expired if expiration time not overpass now.
def remember_expired?
- remember_expires_at <= Time.now
+ remember_expires_at <= Time.now.utc
end
# Remember token expires at created time + remember_for configuration
@@ -4,7 +4,7 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
def setup
setup_mailer
- Notifier.sender = 'test@example.com'
+ DeviseMailer.sender = 'test@example.com'
end
def user
@@ -36,13 +36,13 @@ def mail
end
test 'setup subject from I18n' do
- store_translations :en, :devise => { :notifier => { :confirmation_instructions => 'Account Confirmation' } } do
+ store_translations :en, :devise => { :mailer => { :confirmation_instructions => 'Account Confirmation' } } do
assert_equal 'Account Confirmation', mail.subject
end
end
test 'subject namespaced by model' do
- store_translations :en, :devise => { :notifier => { :user => { :confirmation_instructions => 'User Account Confirmation' } } } do
+ store_translations :en, :devise => { :mailer => { :user => { :confirmation_instructions => 'User Account Confirmation' } } } do
assert_equal 'User Account Confirmation', mail.subject
end
end
@@ -4,7 +4,7 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
def setup
setup_mailer
- Notifier.sender = 'test@example.com'
+ DeviseMailer.sender = 'test@example.com'
end
def user
@@ -39,13 +39,13 @@ def mail
end
test 'setup subject from I18n' do
- store_translations :en, :devise => { :notifier => { :reset_password_instructions => 'Reset instructions' } } do
+ store_translations :en, :devise => { :mailer => { :reset_password_instructions => 'Reset instructions' } } do
assert_equal 'Reset instructions', mail.subject
end
end
test 'subject namespaced by model' do
- store_translations :en, :devise => { :notifier => { :user => { :reset_password_instructions => 'User Reset Instructions' } } } do
+ store_translations :en, :devise => { :mailer => { :user => { :reset_password_instructions => 'User Reset Instructions' } } } do
assert_equal 'User Reset Instructions', mail.subject
end
end
@@ -20,14 +20,6 @@ def setup
assert_not user.changed?
end
- test 'remember_me should calculate expires_at based on remember_for setup' do
- user = create_user
- assert_not user.remember_created_at?
- user.remember_me!
- assert user.remember_created_at?
- assert_equal Date.today, user.remember_created_at.to_date
- end
-
test 'forget_me should clear remember token and save the record without validating' do
user = create_user
user.remember_me!
@@ -38,7 +30,7 @@ def setup
assert_not user.changed?
end
- test 'forget_me should clear remember_expires_at' do
+ test 'forget_me should clear remember_created_at' do
user = create_user
user.remember_me!
assert user.remember_created_at?

0 comments on commit dc86a57

Please sign in to comment.