Commit 91d3e84c5ca89961d5e8c357d19121d1ca0d23b8
1 parent
1df215c3
Exists in
master
and in
29 other branches
ActionItem830: removing locale integration tests
Showing
1 changed file
with
0 additions
and
82 deletions
Show diff stats
test/integration/locale_setting_test.rb
@@ -1,82 +0,0 @@ | @@ -1,82 +0,0 @@ | ||
1 | -require "#{File.dirname(__FILE__)}/../test_helper" | ||
2 | - | ||
3 | -class LocaleSettingTest < ActionController::IntegrationTest | ||
4 | - | ||
5 | - def setup | ||
6 | - # reset GetText before every test | ||
7 | - GetText.locale = nil | ||
8 | - Noosfero.stubs(:default_locale).returns('en') | ||
9 | - Noosfero.stubs(:available_locales).returns(['pt_BR', 'ja_JP']) | ||
10 | - end | ||
11 | - | ||
12 | - should 'be able to set a default language' do | ||
13 | - Noosfero.expects(:default_locale).returns('pt_BR').at_least_once | ||
14 | - | ||
15 | - get '/' | ||
16 | - assert_locale 'pt_BR' | ||
17 | - end | ||
18 | - | ||
19 | - should 'detect locale from the browser' do | ||
20 | - | ||
21 | - # user has pt_BR | ||
22 | - get '/', { }, { 'HTTP_ACCEPT_LANGUAGE' => 'pt-br, en' } | ||
23 | - assert_locale 'pt_BR' | ||
24 | - | ||
25 | - # user now wants en | ||
26 | - get '/', { }, { 'HTTP_ACCEPT_LANGUAGE' => 'en' } | ||
27 | - assert_locale 'en' | ||
28 | - end | ||
29 | - | ||
30 | - should 'not use unsupported browser-informed locale and use C instead' do | ||
31 | - get '/', { }, { 'HTTP_ACCEPT_LANGUAGE' => 'xx-yy, pt-br, en' } | ||
32 | - assert_locale 'en' | ||
33 | - end | ||
34 | - | ||
35 | - should 'fallback to similar languages' do | ||
36 | - # FIXME this assumes pt_PT is unsupported. If a pt_PT translation is added | ||
37 | - # this test will break. | ||
38 | - get '/', { }, { 'HTTP_ACCEPT_LANGUAGE' => 'pt-pt, en' } | ||
39 | - assert_locale 'pt_BR' | ||
40 | - end | ||
41 | - | ||
42 | - should 'accept language without country code and pick a suitable language' do | ||
43 | - get '/', { }, { 'HTTP_ACCEPT_LANGUAGE' => 'pt, en'} | ||
44 | - assert_locale 'pt_BR' | ||
45 | - end | ||
46 | - | ||
47 | - should 'be able to force locale' do | ||
48 | - | ||
49 | - # set locale to pt_BR | ||
50 | - get '/', :lang => 'pt_BR' | ||
51 | - assert_locale 'pt_BR' | ||
52 | - | ||
53 | - # locale is kept | ||
54 | - get '/' | ||
55 | - assert_locale 'pt_BR' | ||
56 | - | ||
57 | - # changing back | ||
58 | - get '/', :lang => 'en' | ||
59 | - assert_locale 'en' | ||
60 | - | ||
61 | - # locale is kept again | ||
62 | - get '/' | ||
63 | - assert_locale 'en' | ||
64 | - | ||
65 | - end | ||
66 | - | ||
67 | - should 'put current language in HTML headers' do | ||
68 | - get '/', :lang => 'pt_BR' | ||
69 | - assert_tag :tag => 'html', :attributes => { 'xml:lang' => 'pt-br', 'lang' => 'pt-br' } | ||
70 | - | ||
71 | - get '/', :lang => 'en' | ||
72 | - assert_tag :tag => 'html', :attributes => { 'xml:lang' => 'en', 'lang' => 'en' } | ||
73 | - end | ||
74 | - | ||
75 | - protected | ||
76 | - | ||
77 | - def assert_locale(locale) | ||
78 | - gettext_locale = GetText.locale.to_s | ||
79 | - ok("Ruby-GetText locale should be #{locale}, but was #{gettext_locale}") { locale == gettext_locale } | ||
80 | - end | ||
81 | - | ||
82 | -end |