# Force ActionMailer to raise delivery errors so we can catch it
ActionMailer::Base.raise_delivery_errors = true
begin
- @test = Mailer.deliver_test(User.current)
+ @test = Mailer.deliver_test_email(User.current)
flash[:notice] = l(:notice_email_sent, User.current.mail)
rescue Exception => e
flash[:error] = l(:notice_email_error, e.message)
render_multipart('register', body)
end
- def test(user)
+ def test_email(user)
set_language_if_valid(user.language)
recipients user.mail
subject 'Redmine test'
body :url => url_for(:controller => 'welcome')
- render_multipart('test', body)
+ render_multipart('test_email', body)
end
# Overrides default deliver! method to prevent from sending an email
+++ /dev/null
-<p>This is a test email sent by Redmine.<br />
-Redmine URL: <%= link_to h(@url), @url %></p>
+++ /dev/null
-This is a test email sent by Redmine.
-Redmine URL: <%= @url %>
--- /dev/null
+<p>This is a test email sent by Redmine.<br />
+Redmine URL: <%= link_to h(@url), @url %></p>
--- /dev/null
+This is a test email sent by Redmine.
+Redmine URL: <%= @url %>
ActionMailer::Base.raise_delivery_errors = true
begin
- Mailer.deliver_test(User.current)
+ Mailer.deliver_test_email(User.current)
puts l(:notice_email_sent, user.mail)
rescue Exception => e
abort l(:notice_email_error, e.message)
end
def test_test_email_failure_should_display_the_error
- Mailer.stubs(:deliver_test).raises(Exception, 'Some error message')
+ Mailer.stubs(:deliver_test_email).raises(Exception, 'Some error message')
get :test_email
assert_redirected_to '/settings/edit?tab=notifications'
assert_match /Some error message/, flash[:error]
def test_from_header
with_settings :mail_from => 'redmine@example.net' do
- Mailer.deliver_test(User.find(1))
+ Mailer.deliver_test_email(User.find(1))
end
mail = last_email
assert_equal 'redmine@example.net', mail.from_addrs.first.address
def test_from_header_with_phrase
with_settings :mail_from => 'Redmine app <redmine@example.net>' do
- Mailer.deliver_test(User.find(1))
+ Mailer.deliver_test_email(User.find(1))
end
mail = last_email
assert_equal 'redmine@example.net', mail.from_addrs.first.address
user = User.find(1)
valid_languages.each do |lang|
user.update_attribute :language, lang.to_s
- assert Mailer.deliver_test(user)
+ assert Mailer.deliver_test_email(user)
end
end
def test_with_deliveries_off
Mailer.with_deliveries false do
- Mailer.deliver_test(User.find(1))
+ Mailer.deliver_test_email(User.find(1))
end
assert ActionMailer::Base.deliveries.empty?
# should restore perform_deliveries
def test_layout_should_include_the_emails_header
with_settings :emails_header => "*Header content*" do
- assert Mailer.deliver_test(User.find(1))
+ assert Mailer.deliver_test_email(User.find(1))
assert_select_email do
assert_select ".header" do
assert_select "strong", :text => "Header content"