comparison test/unit/.svn/text-base/wiki_test.rb.svn-base @ 0:513646585e45

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