aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Fuchs <svenfuchs@artweb-design.de>2008-07-04 22:23:43 +0200
committerSven Fuchs <svenfuchs@artweb-design.de>2008-07-04 22:23:43 +0200
commit35bad508162d4bdbc0c24e11db89cfe16159183e (patch)
treea261385ffcd60b1b88fbdda1fa0eaf0fb98b5688
parente1a7f83fca862fd7472ef6b80f8b6a8d33849a8e (diff)
parentd41e4c1c3d6e6259f1cfc0cdbd4fc30fee0f866a (diff)
downloadrails-35bad508162d4bdbc0c24e11db89cfe16159183e.tar.gz
rails-35bad508162d4bdbc0c24e11db89cfe16159183e.tar.bz2
rails-35bad508162d4bdbc0c24e11db89cfe16159183e.zip
Merge branch 'i18n' of git@github.com:svenfuchs/rails into i18n
-rw-r--r--actionmailer/lib/action_mailer/base.rb4
-rw-r--r--actionmailer/test/i18n_test.rb26
2 files changed, 14 insertions, 16 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index f7da90d10f..a1a7f55d2b 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -346,10 +346,10 @@ module ActionMailer #:nodoc:
# Specify the charset to use for the message.
# It performs a lookup, on the specified charset, then on the charset from
- # the current locale, and, finally, on the +default_charset+ specified
+ # the current locale, and, in the end, on the +default_charset+ specified
# for ActionMailer::Base.
def charset(charset = nil)
- @charset ||= charset || I18n.translate(:charset) || @@default_charset
+ @charset ||= charset || I18n.translate(:charset, :default => @@default_charset)
end
attr_writer :charset
diff --git a/actionmailer/test/i18n_test.rb b/actionmailer/test/i18n_test.rb
index 92b128bce6..a775128519 100644
--- a/actionmailer/test/i18n_test.rb
+++ b/actionmailer/test/i18n_test.rb
@@ -59,37 +59,35 @@ class I18nTest < Test::Unit::TestCase
end
def test_should_use_default_charset_if_no_current_locale
- uses_locale nil do
+ with_locale nil do
assert_equal @charset, mail.charset
end
end
def test_mail_headers_should_contains_current_charset
- uses_locale 'de-DE' do
+ with_locale 'de-DE' do
assert_match /iso-8859-1/, mail.header['content-type'].body
end
end
def test_should_use_charset_from_current_locale
- uses_locale 'de-DE' do
+ with_locale 'de-DE' do
assert_equal 'iso-8859-1', mail.charset
end
end
-
- def test_should_raise_exception_if_current_locale_doesnt_specify_a_charset
- assert_raise I18n::MissingTranslationData do
- uses_locale 'en-GB' do
- mail
- end
+
+ def test_should_use_default_charset_if_missing_for_current_locale
+ with_locale 'en-GB' do
+ assert_equal @charset, mail.charset
end
end
-
+
def test_should_use_explicit_charset
assert_equal 'iso-8859-2', mail('use_explicit_charset').charset
end
def test_mail_parts_charsets
- uses_locale 'de-DE' do
+ with_locale 'de-DE' do
charsets = mail('multiparted').parts.map(&:charset)
assert_equal 'iso-8859-1', charsets[0]
assert_equal 'iso-8859-1', charsets[1]
@@ -98,7 +96,7 @@ class I18nTest < Test::Unit::TestCase
end
def test_mail_parts_headers
- uses_locale 'de-DE' do
+ with_locale 'de-DE' do
content_types = mail('multiparted').parts.map(&:header).map do |header|
header['content-type'].body
end
@@ -111,7 +109,7 @@ class I18nTest < Test::Unit::TestCase
# TODO: this case depends on XML Builder,
# should we pass Builder::XmlMarkup.new :encoding => charset_from_i18n ?
def _ignore_test_rxml_template_should_use_current_charset
- uses_locale 'de-DE' do
+ with_locale 'de-DE' do
assert_equal "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<test/>",
mail('rxml_template').body.strip
end
@@ -122,7 +120,7 @@ class I18nTest < Test::Unit::TestCase
I18nMailer.__send__('create_' + method, @recipient)
end
- def uses_locale(locale, &block)
+ def with_locale(locale, &block)
begin
I18n.locale = locale
yield