Skip to content

Instantly share code, notes, and snippets.

@lifo
Created August 26, 2010 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lifo/551772 to your computer and use it in GitHub Desktop.
Save lifo/551772 to your computer and use it in GitHub Desktop.
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index fb42ccb..c110810 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 0000000..30466dd
--- /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 2c6de36..e89a582 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment