From ac010fc840225a590450d0820353f369bc0f3a31 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Fri, 5 Feb 2010 20:56:36 -0300 Subject: [PATCH] Making tests pass --- app/helpers/application_helper.rb | 1 + test/functional/doc_controller_test.rb | 8 ++++---- test/unit/application_helper_test.rb | 2 ++ test/unit/doc_section_test.rb | 26 +++++++++++++------------- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 692dfb2..ad7b57a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -362,6 +362,7 @@ module ApplicationHelper return render :file => file, :use_full_path => false end end + nil end def theme_header diff --git a/test/functional/doc_controller_test.rb b/test/functional/doc_controller_test.rb index 9c82f55..b03644a 100644 --- a/test/functional/doc_controller_test.rb +++ b/test/functional/doc_controller_test.rb @@ -23,20 +23,20 @@ class DocControllerTest < ActionController::TestCase end should 'translate section' do - get :section, :section => 'admin' + get :section, :section => 'user' assert_equal 'en', assigns(:section).language @controller.stubs(:language).returns('pt') - get :section, :section => 'admin' + get :section, :section => 'user' assert_equal 'pt', assigns(:section).language end should 'translate topic' do - get :topic, :section => 'admin', :topic => '100-email' + get :topic, :section => 'user', :topic => 'accepting-friends' assert_equal 'en', assigns(:topic).language @controller.stubs(:language).returns('pt') - get :topic, :section => 'admin', :topic => '100-email' + get :topic, :section => 'user', :topic => 'accepting-friends' assert_equal 'pt', assigns(:topic).language end diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index 264652b..f5e622f 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -170,8 +170,10 @@ class ApplicationHelperTest < Test::Unit::TestCase should 'ignore unexisting theme footer' do stubs(:theme_path).returns('/user_themes/mytheme') footer_path = RAILS_ROOT + '/public/user_themes/mytheme/footer.rhtml' + alternate_footer_path = RAILS_ROOT + '/public/user_themes/mytheme/footer.html.erb' File.expects(:exists?).with(footer_path).returns(false) + File.expects(:exists?).with(alternate_footer_path).returns(false) expects(:render).with(:file => footer).never assert_nil theme_footer diff --git a/test/unit/doc_section_test.rb b/test/unit/doc_section_test.rb index a0c2bcc..8912f31 100644 --- a/test/unit/doc_section_test.rb +++ b/test/unit/doc_section_test.rb @@ -21,7 +21,7 @@ class DocSectionTest < ActiveSupport::TestCase should 'list available sections' do sections = DocSection.all assert(sections.size > 0, 'should load sections ') - assert(sections.find { |item| item.title == 'Administration'}, 'should find section "Administration"') + assert(sections.find { |item| item.title == 'Content Management'}, 'should find section "Content Management"') assert(sections.find { |item| item.title == 'User features'}, 'should find section "User features"') end @@ -30,7 +30,7 @@ class DocSectionTest < ActiveSupport::TestCase # break. If those translations change, this test will also break. should 'list section for a given language' do sections = DocSection.all('pt') - assert(sections.find { |item| item.title == 'Administração'}, 'should find section "Administration" translated') + assert(sections.find { |item| item.title == 'Gerenciamento de conteúdo'}, 'should find section "Content Management" translated') assert(sections.find { |item| item.title == 'Funcionalidades de Usuário'}, 'should find section "User features" translated') end @@ -46,28 +46,28 @@ class DocSectionTest < ActiveSupport::TestCase # This test also depends on the existance of specific documentation sections. # The same conditions as the above tests apply. should 'list items' do - section = DocSection.all.find {|item| item.title == 'Administration' } + section = DocSection.all.find {|item| item.title == 'Content Management' } assert section.items.size > 0, "should load at least one item" - assert section.items.find {|item| item.title == 'E-mail settings' && item.text =~ /

E-mail settings/ }, 'should find "E-mail settings" topic' - assert section.items.find {|item| item.title == 'Managing user roles' && item.text =~ /

Managing/ }, 'should find "Managing user roles" topic' + assert section.items.find {|item| item.title == 'Adding pictures to gallery' && item.text =~ /

Adding pictures to gallery/ }, 'should find "Adding pictures to gallery" topic' + assert section.items.find {|item| item.title == 'Creating a blog' && item.text =~ /

Creating a blog/ }, 'should find "Creating a blog" topic' end # This test assumes ... (yada, yada, yada, the same as above) should 'load translated items' do - section = DocSection.all('pt').find {|item| item.title == 'Administração' } + section = DocSection.all('pt').find {|item| item.title == 'Gerenciamento de conteúdo' } assert section.items.size > 0, "should load at least one item" - assert section.items.find {|item| item.title == 'Configurações de e-mail' && item.text =~ /

Configurações/ }, 'should find translated "E-mail settings" topic' - assert section.items.find {|item| item.title == 'Gerenciando papéis de usuários' && item.text =~ /

Gerenciando/ }, 'should find translated "Managing user roles" topic' + assert section.items.find {|item| item.title == 'Adicionando fotos na galeria' && item.text =~ /

Adicionando fotos na galeria/ }, 'should find translated "Adding pictures to gallery" topic' + assert section.items.find {|item| item.title == 'Criando um blog' && item.text =~ /

Criando um blog/ }, 'should find translated "Creating a blog" topic' end # This test assumes that Klingon (tlh) is not supported. If Noosfero does get # aa Klingon translation, then this test will fail should 'fallback to load original items when translation is not available' do - section = DocSection.find('admin', 'tlh') - assert_equal 'Administration', section.title + section = DocSection.find('user', 'tlh') + assert_equal 'User features', section.title - topic = section.find('100-email') - assert_equal 'E-mail settings', topic.title + topic = section.find('accepting-friends') + assert_equal 'Accepting friends', topic.title end should 'find in items' do @@ -80,8 +80,8 @@ class DocSectionTest < ActiveSupport::TestCase end should 'be able to find section by its id' do - assert_equal "Administration", DocSection.find('admin').title assert_equal "User features", DocSection.find('user').title + assert_equal "Content Management", DocSection.find('cms').title end should 'load null section (the root)' do -- libgit2 0.21.2