diff options
author | José Valim <jose.valim@gmail.com> | 2010-08-26 15:19:55 -0300 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-08-26 16:07:54 -0300 |
commit | 84cab320bc1faaddc142cbbb38713d3f29a8b07d (patch) | |
tree | f165c9c3a9d5544c194affc54382e02025cdf73c | |
parent | d728f0858014cf284f501f169f13d8cd1da36ab7 (diff) | |
download | rails-84cab320bc1faaddc142cbbb38713d3f29a8b07d.tar.gz rails-84cab320bc1faaddc142cbbb38713d3f29a8b07d.tar.bz2 rails-84cab320bc1faaddc142cbbb38713d3f29a8b07d.zip |
Ensure templates like template.html are found but still uses the proper virtual path.
-rw-r--r-- | actionmailer/test/base_test.rb | 6 | ||||
-rw-r--r-- | actionmailer/test/fixtures/base_mailer/email_with_translations.html.erb | 1 | ||||
-rw-r--r-- | actionmailer/test/mailers/base_mailer.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_view/template.rb | 7 |
4 files changed, 15 insertions, 3 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index fb42ccb8aa..c11081072d 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -209,6 +209,12 @@ class BaseTest < ActiveSupport::TestCase assert_equal "New Subject!", email.subject end + test "translations are scoped properly" do + I18n.backend.store_translations('en', :base_mailer => {:email_with_translations => {:greet_user => "Hello %{name}!"}}) + email = BaseMailer.email_with_translations + assert_equal 'Hello lifo!', email.body.encoded + end + # Implicit multipart test "implicit multipart" do email = BaseMailer.implicit_multipart diff --git a/actionmailer/test/fixtures/base_mailer/email_with_translations.html.erb b/actionmailer/test/fixtures/base_mailer/email_with_translations.html.erb new file mode 100644 index 0000000000..30466dd005 --- /dev/null +++ b/actionmailer/test/fixtures/base_mailer/email_with_translations.html.erb @@ -0,0 +1 @@ +<%= t('.greet_user', :name => 'lifo') %>
\ No newline at end of file diff --git a/actionmailer/test/mailers/base_mailer.rb b/actionmailer/test/mailers/base_mailer.rb index 2c6de36ccf..e89a5820cc 100644 --- a/actionmailer/test/mailers/base_mailer.rb +++ b/actionmailer/test/mailers/base_mailer.rb @@ -111,4 +111,8 @@ class BaseMailer < ActionMailer::Base format.html { render :layout => layout_name } end end + + def email_with_translations + body render("email_with_translations.html") + end end diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index 40ff1f2182..7decec24ab 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -113,12 +113,13 @@ module ActionView @identifier = identifier @handler = handler @original_encoding = nil - - @virtual_path = details[:virtual_path] - @method_names = {} + @method_names = {} format = details[:format] || :html @formats = Array.wrap(format).map(&:to_sym) + + @virtual_path = details[:virtual_path] + @virtual_path.sub!(".#{format}", "") if @virtual_path end def render(view, locals, &block) |