diff --git a/test/functional/application_controller_test.rb b/test/functional/application_controller_test.rb index f9891ab..d6d2b29 100644 --- a/test/functional/application_controller_test.rb +++ b/test/functional/application_controller_test.rb @@ -143,4 +143,23 @@ class ApplicationControllerTest < Test::Unit::TestCase assert_no_tag :tag => 'a', :content => /Category 2/ end + should 'display dropdown for select language' do + Noosfero.expects(:locales).returns({ 'en' => 'English', 'pt_BR' => 'Português Brasileiro', 'fr' => 'Français', 'it' => 'Italiano' }).at_least_once + get :index, :lang => 'en' + assert_tag :tag => 'option', :attributes => { :value => 'en', :selected => 'selected' }, :content => 'English' + assert_no_tag :tag => 'option', :attributes => { :value => 'pt_BR', :selected => 'selected' }, :content => 'Português Brasileiro' + assert_tag :tag => 'option', :attributes => { :value => 'pt_BR' }, :content => 'Português Brasileiro' + assert_tag :tag => 'option', :attributes => { :value => 'fr' }, :content => 'Français' + assert_tag :tag => 'option', :attributes => { :value => 'it' }, :content => 'Italiano' + end + + should 'display links for select language' do + Noosfero.expects(:locales).returns({ 'en' => 'English', 'pt_BR' => 'Português Brasileiro', 'fr' => 'Français', 'it' => 'Italiano' }).at_least_once + get :index, :lang => 'en' + assert_no_tag :tag => 'a', :attributes => { :href => /\?lang=en/ }, :content => 'English' + assert_tag :tag => 'a', :attributes => { :href => /\?lang=pt_BR/ }, :content => 'Português Brasileiro' + assert_tag :tag => 'a', :attributes => { :href => /\?lang=fr/ }, :content => 'Français' + assert_tag :tag => 'a', :attributes => { :href => /\?lang=it/ }, :content => 'Italiano' + end + end diff --git a/test/unit/language_helper_test.rb b/test/unit/language_helper_test.rb index 4d02857..29e718e 100644 --- a/test/unit/language_helper_test.rb +++ b/test/unit/language_helper_test.rb @@ -4,6 +4,7 @@ class LanguageHelperTest < Test::Unit::TestCase include LanguageHelper + should 'return current language' do locale = mock locale.expects(:to_s).returns('pt_BR') @@ -36,25 +37,20 @@ class LanguageHelperTest < Test::Unit::TestCase end + include ActionView::Helpers::FormOptionsHelper + include ActionView::Helpers::FormTagHelper should 'generate drodown language chooser correcly' do Noosfero.expects(:locales).returns({ 'en' => 'English', 'pt_BR' => 'Português Brasileiro', 'fr' => 'Français', 'it' => 'Italiano' }).at_least_once - self.expects(:language).returns('pt_BR') + self.expects(:language).returns('en') result = self.language_chooser(:element => 'dropdown') assert_match /