Permalink
Browse files

Add tests for mail with proc.

  • Loading branch information...
1 parent 3711961 commit 6bb1901830e71ac3c0837556ca732fdb6991a14b @josevalim josevalim committed Jan 13, 2010
View
@@ -1,3 +1,6 @@
+* bug fix
+ * Fix bug with passenger, update is required to anyone deploying on passenger
+
== 0.8.1
* enhancements
@@ -19,7 +19,7 @@ def setup_mail(record, key)
raise "Invalid devise resource #{record}" unless mapping
subject translate(mapping, key)
- from Devise.mailer_sender.is_a?(Proc) ? Devise.mailer_sender.call(mapping.name) : Devise.mailer_sender
+ from mailer_sender(mapping)
recipients record.email
sent_on Time.now
content_type 'text/html'
@@ -38,6 +38,14 @@ def render_with_scope(key, mapping, assigns)
end
end
+ def mailer_sender(mapping)
+ if Devise.mailer_sender.is_a?(Proc)
+ Devise.mailer_sender.call(mapping.name)
+ else
+ Devise.mailer_sender
+ end
+ end
+
# Setup subject namespaced by model. It means you're able to setup your
# messages using specific resource scope, or provide a default one.
# Example (i18n locale file):
@@ -1,5 +1,5 @@
# After each sign in, update sign in time, sign in count and sign in IP.
-Warden::Manager.after_set_user :event => [:authentication, :set_user] do |record, warden, options|
+Warden::Manager.after_set_user :except => :fetch do |record, warden, options|
scope = options[:scope]
if Devise.mappings[scope].try(:trackable?) && warden.authenticated?(scope)
old_current, new_current = record.current_sign_in_at, Time.now
@@ -62,4 +62,10 @@ def mail
assert_equal user.email, mail.body
end
end
+
+ test 'mailer sender accepts a proc' do
+ swap Devise, :mailer_sender => lambda { "another@example.com" } do
+ assert_equal ['another@example.com'], mail.from
+ end
+ end
end
@@ -59,4 +59,10 @@ def mail
reset_url_regexp = %r{<a href=\"http://#{host}/users/password/edit\?reset_password_token=#{user.reset_password_token}">}
assert_match reset_url_regexp, mail.body
end
+
+ test 'mailer sender accepts a proc' do
+ swap Devise, :mailer_sender => lambda { "another@example.com" } do
+ assert_equal ['another@example.com'], mail.from
+ end
+ end
end

0 comments on commit 6bb1901

Please sign in to comment.