Merged updates from trunk into stable branch
[feedcatcher.git] / vendor / rails / actionpack / test / template / translation_helper_test.rb
1 require 'abstract_unit'
2
3 class TranslationHelperTest < Test::Unit::TestCase
4 include ActionView::Helpers::TagHelper
5 include ActionView::Helpers::TranslationHelper
6
7 attr_reader :request
8 def setup
9 end
10
11 def test_delegates_to_i18n_setting_the_raise_option
12 I18n.expects(:translate).with(:foo, :locale => 'en', :raise => true)
13 translate :foo, :locale => 'en'
14 end
15
16 def test_returns_missing_translation_message_wrapped_into_span
17 expected = '<span class="translation_missing">en, foo</span>'
18 assert_equal expected, translate(:foo)
19 end
20
21 def test_delegates_localize_to_i18n
22 @time = Time.utc(2008, 7, 8, 12, 18, 38)
23 I18n.expects(:localize).with(@time)
24 localize @time
25 end
26
27 def test_scoping_by_partial
28 expects(:template).returns(stub(:path_without_format_and_extension => "people/index"))
29 I18n.expects(:translate).with("people.index.foo", :locale => 'en', :raise => true)
30 translate ".foo", :locale => 'en'
31 end
32 end