annotate test/unit/wiki_test.rb @ 864:2465362d1b56 bug_145

Close obsolete branch bug_145
author Chris Cannam
date Wed, 11 May 2011 11:57:41 +0100
parents 513646585e45
children af80e5618e9b 8661b858af72
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@0 20 require File.dirname(__FILE__) + '/../test_helper'
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@0 42 def test_titleize
Chris@0 43 assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES')
Chris@0 44 assert_equal 'テスト', Wiki.titleize('テスト')
Chris@0 45 end
Chris@0 46
Chris@0 47 context "#sidebar" do
Chris@0 48 setup do
Chris@0 49 @wiki = Wiki.find(1)
Chris@0 50 end
Chris@0 51
Chris@0 52 should "return nil if undefined" do
Chris@0 53 assert_nil @wiki.sidebar
Chris@0 54 end
Chris@0 55
Chris@0 56 should "return a WikiPage if defined" do
Chris@0 57 page = @wiki.pages.new(:title => 'Sidebar')
Chris@0 58 page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
Chris@0 59 page.save!
Chris@0 60
Chris@0 61 assert_kind_of WikiPage, @wiki.sidebar
Chris@0 62 assert_equal 'Sidebar', @wiki.sidebar.title
Chris@0 63 end
Chris@0 64 end
Chris@0 65 end