2011-01-14 03:32:51 -05:00
|
|
|
require 'abstract_unit'
|
|
|
|
require 'action_controller'
|
|
|
|
|
|
|
|
class I18nTestMailer < ActionMailer::Base
|
|
|
|
configure do |c|
|
2011-01-19 17:42:10 -05:00
|
|
|
c.assets_dir = ''
|
2011-01-14 03:32:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def mail_with_i18n_subject(recipient)
|
2011-01-19 17:42:10 -05:00
|
|
|
@recipient = recipient
|
2011-01-14 03:32:51 -05:00
|
|
|
I18n.locale = :de
|
|
|
|
mail(:to => recipient, :subject => "#{I18n.t :email_subject} #{recipient}",
|
|
|
|
:from => "system@loudthinking.com", :date => Time.local(2004, 12, 12))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class TestController < ActionController::Base
|
|
|
|
def send_mail
|
2011-01-19 17:42:10 -05:00
|
|
|
I18nTestMailer.mail_with_i18n_subject("test@localhost").deliver
|
2011-01-14 03:32:51 -05:00
|
|
|
render :text => 'Mail sent'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class ActionMailerI18nWithControllerTest < ActionDispatch::IntegrationTest
|
|
|
|
Routes = ActionDispatch::Routing::RouteSet.new
|
|
|
|
Routes.draw do
|
2012-04-25 00:55:39 -04:00
|
|
|
get ':controller(/:action(/:id))'
|
2011-01-14 03:32:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def app
|
|
|
|
Routes
|
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
|
|
|
I18n.backend.store_translations('de', :email_subject => '[Signed up] Welcome')
|
2011-01-19 17:42:10 -05:00
|
|
|
end
|
2011-01-14 03:32:51 -05:00
|
|
|
|
2011-01-19 17:42:10 -05:00
|
|
|
def teardown
|
|
|
|
I18n.locale = :en
|
2011-01-14 03:32:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_send_mail
|
|
|
|
get '/test/send_mail'
|
|
|
|
assert_equal "Mail sent", @response.body
|
|
|
|
end
|
|
|
|
end
|