2011-01-14 03:32:51 -05:00
|
|
|
require 'abstract_unit'
|
2013-07-17 09:13:16 -04:00
|
|
|
require 'action_view'
|
2011-01-14 03:32:51 -05:00
|
|
|
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
|
2012-10-07 13:54:14 -04:00
|
|
|
mail(to: recipient, subject: "#{I18n.t :email_subject} #{recipient}",
|
|
|
|
from: "system@loudthinking.com", date: Time.local(2004, 12, 12))
|
2011-01-14 03:32:51 -05:00
|
|
|
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
|
2012-10-07 13:54:14 -04:00
|
|
|
render text: 'Mail sent'
|
2011-01-14 03:32:51 -05:00
|
|
|
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
|
2012-10-07 13:54:14 -04:00
|
|
|
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
|