annotate test/unit/wiki_test.rb @ 904:0a8317a50fa0 redmine-1.1

Close obsolete branch redmine-1.1
author Chris Cannam
date Fri, 14 Jan 2011 12:53:21 +0000
parents af80e5618e9b
children cd2282d2aa55
rev   line source
Chris@0 1 # encoding: utf-8
Chris@0 2 #
Chris@0 3 # redMine - project management software
Chris@0 4 # Copyright (C) 2006-2007 Jean-Philippe Lang
Chris@0 5 #
Chris@0 6 # This program is free software; you can redistribute it and/or
Chris@0 7 # modify it under the terms of the GNU General Public License
Chris@0 8 # as published by the Free Software Foundation; either version 2
Chris@0 9 # of the License, or (at your option) any later version.
Chris@0 10 #
Chris@0 11 # This program is distributed in the hope that it will be useful,
Chris@0 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 14 # GNU General Public License for more details.
Chris@0 15 #
Chris@0 16 # You should have received a copy of the GNU General Public License
Chris@0 17 # along with this program; if not, write to the Free Software
Chris@0 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 19
Chris@117 20 require File.expand_path('../../test_helper', __FILE__)
Chris@0 21
Chris@0 22 class WikiTest < ActiveSupport::TestCase
Chris@0 23 fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
Chris@0 24
Chris@0 25 def test_create
Chris@0 26 wiki = Wiki.new(:project => Project.find(2))
Chris@0 27 assert !wiki.save
Chris@0 28 assert_equal 1, wiki.errors.count
Chris@0 29
Chris@0 30 wiki.start_page = "Start page"
Chris@0 31 assert wiki.save
Chris@0 32 end
Chris@0 33
Chris@0 34 def test_update
Chris@0 35 @wiki = Wiki.find(1)
Chris@0 36 @wiki.start_page = "Another start page"
Chris@0 37 assert @wiki.save
Chris@0 38 @wiki.reload
Chris@0 39 assert_equal "Another start page", @wiki.start_page
Chris@0 40 end
Chris@0 41
Chris@117 42 def test_find_page
Chris@117 43 wiki = Wiki.find(1)
Chris@117 44 page = WikiPage.find(2)
Chris@117 45
Chris@117 46 assert_equal page, wiki.find_page('Another_page')
Chris@117 47 assert_equal page, wiki.find_page('Another page')
Chris@117 48 assert_equal page, wiki.find_page('ANOTHER page')
Chris@117 49 end
Chris@117 50
Chris@0 51 def test_titleize
Chris@0 52 assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES')
Chris@0 53 assert_equal 'テスト', Wiki.titleize('テスト')
Chris@0 54 end
Chris@0 55
Chris@0 56 context "#sidebar" do
Chris@0 57 setup do
Chris@0 58 @wiki = Wiki.find(1)
Chris@0 59 end
Chris@0 60
Chris@0 61 should "return nil if undefined" do
Chris@0 62 assert_nil @wiki.sidebar
Chris@0 63 end
Chris@0 64
Chris@0 65 should "return a WikiPage if defined" do
Chris@0 66 page = @wiki.pages.new(:title => 'Sidebar')
Chris@0 67 page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
Chris@0 68 page.save!
Chris@0 69
Chris@0 70 assert_kind_of WikiPage, @wiki.sidebar
Chris@0 71 assert_equal 'Sidebar', @wiki.sidebar.title
Chris@0 72 end
Chris@0 73 end
Chris@0 74 end