# encoding: UTF-8 require_relative "../test_helper" class DocSectionTest < ActiveSupport::TestCase include Noosfero::DocTest def setup setup_doc_test end def tear_down tear_down_doc_test end should 'be a DocItem' do assert_kind_of DocItem, DocSection.new end should 'have a list of items' do assert_kind_of Array, DocSection.new.items end should 'be able to add items' do section = DocSection.new item = DocItem.new(:title => 'test') section.items << item assert_equal item, section.items.first end # This test assumes the existance of some sample documentation sections. If # they are removed or retitled this test will break should 'list available sections' do sections = DocSection.all assert(sections.size > 0, 'should load sections ') 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 # This test assumes the same as the above test, plus a specific translation # for the section names. If the test above breaks, this one will probably # 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 == '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 should 'indicate the language when loading sections' do DocSection.all.each do |section| assert_equal 'en', section.language, 'should indicate default language' end DocSection.all('pt').each do |section| assert_equal 'pt', section.language, 'should indicate Portuguese' end end # 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 == 'Content Management' } assert section.items.size > 0, "should load at least one item" assert section.items.find {|item| item.title == 'Adding pictures to gallery' && item.text =~ /