da84a2c8434b13f5313e3d303494d26dfb3e1b18
[packages/precise/mcollective.git] / lib / mcollective / vendor / i18n / lib / i18n / tests / link.rb
1 # encoding: utf-8
2
3 module I18n
4   module Tests
5     module Link
6       test "linked lookup: if a key resolves to a symbol it looks up the symbol" do
7         I18n.backend.store_translations 'en', {
8           :link  => :linked,
9           :linked => 'linked'
10         }
11         assert_equal 'linked', I18n.backend.translate('en', :link)
12       end
13
14       test "linked lookup: if a key resolves to a dot-separated symbol it looks up the symbol" do
15         I18n.backend.store_translations 'en', {
16           :link => :"foo.linked",
17           :foo  => { :linked => 'linked' }
18         }
19         assert_equal('linked', I18n.backend.translate('en', :link))
20       end
21
22       test "linked lookup: if a dot-separated key resolves to a symbol it looks up the symbol" do
23         I18n.backend.store_translations 'en', {
24           :foo    => { :link => :linked },
25           :linked => 'linked'
26         }
27         assert_equal('linked', I18n.backend.translate('en', :'foo.link'))
28       end
29       
30       test "linked lookup: if a dot-separated key resolves to a dot-separated symbol it looks up the symbol" do
31         I18n.backend.store_translations 'en', {
32           :foo => { :link   => :"bar.linked" },
33           :bar => { :linked => 'linked' }
34         }
35         assert_equal('linked', I18n.backend.translate('en', :'foo.link'))
36       end
37
38       test "linked lookup: links always refer to the absolute key" do
39         I18n.backend.store_translations 'en', {
40           :foo => { :link => :linked, :linked => 'linked in foo' },
41           :linked => 'linked absolutely'
42         }
43         assert_equal 'linked absolutely', I18n.backend.translate('en', :link, :scope => :foo)
44       end
45
46       test "linked lookup: a link can resolve to a namespace in the middle of a dot-separated key" do
47         I18n.backend.store_translations 'en', {
48           :activemodel  => { :errors => { :messages => { :blank => "can't be blank" } } },
49           :activerecord => { :errors => { :messages => :"activemodel.errors.messages" } }
50         }
51         assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank")
52         assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank")
53       end
54     end
55   end
56 end