Skip to content
This repository
Browse code

Ensure templates like template.html are found but still uses the prop…

…er virtual path.
  • Loading branch information...
commit 84cab320bc1faaddc142cbbb38713d3f29a8b07d 1 parent d728f08
José Valim authored August 26, 2010
6  actionmailer/test/base_test.rb
@@ -209,6 +209,12 @@ def teardown
209 209
     assert_equal "New Subject!", email.subject
210 210
   end
211 211
 
  212
+  test "translations are scoped properly" do
  213
+    I18n.backend.store_translations('en', :base_mailer => {:email_with_translations => {:greet_user => "Hello %{name}!"}})
  214
+    email = BaseMailer.email_with_translations
  215
+    assert_equal 'Hello lifo!', email.body.encoded
  216
+  end
  217
+
212 218
   # Implicit multipart
213 219
   test "implicit multipart" do
214 220
     email = BaseMailer.implicit_multipart
1  actionmailer/test/fixtures/base_mailer/email_with_translations.html.erb
... ...
@@ -0,0 +1 @@
  1
+<%= t('.greet_user', :name => 'lifo') %>
4  actionmailer/test/mailers/base_mailer.rb
@@ -111,4 +111,8 @@ def different_layout(layout_name='')
111 111
       format.html { render :layout => layout_name }
112 112
     end
113 113
   end
  114
+
  115
+  def email_with_translations
  116
+    body render("email_with_translations.html")
  117
+  end
114 118
 end
7  actionpack/lib/action_view/template.rb
@@ -113,12 +113,13 @@ def initialize(source, identifier, handler, details)
113 113
       @identifier         = identifier
114 114
       @handler            = handler
115 115
       @original_encoding  = nil
116  
-
117  
-      @virtual_path = details[:virtual_path]
118  
-      @method_names = {}
  116
+      @method_names       = {}
119 117
 
120 118
       format   = details[:format] || :html
121 119
       @formats = Array.wrap(format).map(&:to_sym)
  120
+
  121
+      @virtual_path = details[:virtual_path]
  122
+      @virtual_path.sub!(".#{format}", "") if @virtual_path
122 123
     end
123 124
 
124 125
     def render(view, locals, &block)

0 notes on commit 84cab32

Please sign in to comment.
Something went wrong with that request. Please try again.