Skip to content

Commit

Permalink
Default sent_on time to now in ActionMailer
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#2607 state:committed]
  • Loading branch information
mrduncan authored and NZKoz committed Aug 8, 2009
1 parent e1d27ee commit f73d34c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions actionmailer/lib/action_mailer/base.rb
Expand Up @@ -543,6 +543,7 @@ def initialize_defaults(method_name)
@headers ||= {}
@body ||= {}
@mime_version = @@default_mime_version.dup if @@default_mime_version
@sent_on ||= Time.now
end

def render_message(method_name, body)
Expand Down
5 changes: 3 additions & 2 deletions actionmailer/test/mail_service_test.rb
Expand Up @@ -18,7 +18,6 @@ def signed_up(recipient)
@recipients = recipient
@subject = "[Signed up] Welcome #{recipient}"
@from = "system@loudthinking.com"
@sent_on = Time.local(2004, 12, 12)
@body["recipient"] = recipient
end

Expand Down Expand Up @@ -356,12 +355,14 @@ def test_attachment_with_custom_header
end

def test_signed_up
Time.stubs(:now => Time.now)

expected = new_mail
expected.to = @recipient
expected.subject = "[Signed up] Welcome #{@recipient}"
expected.body = "Hello there, \n\nMr. #{@recipient}"
expected.from = "system@loudthinking.com"
expected.date = Time.local(2004, 12, 12)
expected.date = Time.now

created = nil
assert_nothing_raised { created = TestMailer.create_signed_up(@recipient) }
Expand Down

0 comments on commit f73d34c

Please sign in to comment.