@@ -7,12 +7,12 | |||||
7 | # modify it under the terms of the GNU General Public License |
|
7 | # modify it under the terms of the GNU General Public License | |
8 | # as published by the Free Software Foundation; either version 2 |
|
8 | # as published by the Free Software Foundation; either version 2 | |
9 | # of the License, or (at your option) any later version. |
|
9 | # of the License, or (at your option) any later version. | |
10 |
# |
|
10 | # | |
11 | # This program is distributed in the hope that it will be useful, |
|
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. |
|
14 | # GNU General Public License for more details. | |
15 |
# |
|
15 | # | |
16 | # You should have received a copy of the GNU General Public License |
|
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 |
|
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. |
|
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
@@ -21,12 +21,12 require File.expand_path('../../test_helper', __FILE__) | |||||
21 |
|
21 | |||
22 | class WikiTest < ActiveSupport::TestCase |
|
22 | class WikiTest < ActiveSupport::TestCase | |
23 | fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions |
|
23 | fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions | |
24 |
|
24 | |||
25 | def test_create |
|
25 | def test_create | |
26 | wiki = Wiki.new(:project => Project.find(2)) |
|
26 | wiki = Wiki.new(:project => Project.find(2)) | |
27 | assert !wiki.save |
|
27 | assert !wiki.save | |
28 | assert_equal 1, wiki.errors.count |
|
28 | assert_equal 1, wiki.errors.count | |
29 |
|
29 | |||
30 | wiki.start_page = "Start page" |
|
30 | wiki.start_page = "Start page" | |
31 | assert wiki.save |
|
31 | assert wiki.save | |
32 | end |
|
32 | end | |
@@ -38,28 +38,28 class WikiTest < ActiveSupport::TestCase | |||||
38 | @wiki.reload |
|
38 | @wiki.reload | |
39 | assert_equal "Another start page", @wiki.start_page |
|
39 | assert_equal "Another start page", @wiki.start_page | |
40 | end |
|
40 | end | |
41 |
|
41 | |||
42 | def test_find_page_should_not_be_case_sensitive |
|
42 | def test_find_page_should_not_be_case_sensitive | |
43 | wiki = Wiki.find(1) |
|
43 | wiki = Wiki.find(1) | |
44 | page = WikiPage.find(2) |
|
44 | page = WikiPage.find(2) | |
45 |
|
45 | |||
46 | assert_equal page, wiki.find_page('Another_page') |
|
46 | assert_equal page, wiki.find_page('Another_page') | |
47 | assert_equal page, wiki.find_page('Another page') |
|
47 | assert_equal page, wiki.find_page('Another page') | |
48 | assert_equal page, wiki.find_page('ANOTHER page') |
|
48 | assert_equal page, wiki.find_page('ANOTHER page') | |
49 | end |
|
49 | end | |
50 |
|
50 | |||
51 | def test_find_page_with_cyrillic_characters |
|
51 | def test_find_page_with_cyrillic_characters | |
52 | wiki = Wiki.find(1) |
|
52 | wiki = Wiki.find(1) | |
53 | page = WikiPage.find(10) |
|
53 | page = WikiPage.find(10) | |
54 | assert_equal page, wiki.find_page('Этика_менеджмента') |
|
54 | assert_equal page, wiki.find_page('Этика_менеджмента') | |
55 | end |
|
55 | end | |
56 |
|
56 | |||
57 | def test_find_page_with_backslashes |
|
57 | def test_find_page_with_backslashes | |
58 | wiki = Wiki.find(1) |
|
58 | wiki = Wiki.find(1) | |
59 | page = WikiPage.generate!(:wiki => wiki, :title => '2009\\02\\09') |
|
59 | page = WikiPage.generate!(:wiki => wiki, :title => '2009\\02\\09') | |
60 | assert_equal page, wiki.find_page('2009\\02\\09') |
|
60 | assert_equal page, wiki.find_page('2009\\02\\09') | |
61 | end |
|
61 | end | |
62 |
|
62 | |||
63 | def test_find_page_without_redirect |
|
63 | def test_find_page_without_redirect | |
64 | wiki = Wiki.find(1) |
|
64 | wiki = Wiki.find(1) | |
65 | page = wiki.find_page('Another_page') |
|
65 | page = wiki.find_page('Another_page') | |
@@ -67,7 +67,7 class WikiTest < ActiveSupport::TestCase | |||||
67 | assert_equal 'Another_page', page.title |
|
67 | assert_equal 'Another_page', page.title | |
68 | assert_equal false, wiki.page_found_with_redirect? |
|
68 | assert_equal false, wiki.page_found_with_redirect? | |
69 | end |
|
69 | end | |
70 |
|
70 | |||
71 | def test_find_page_with_redirect |
|
71 | def test_find_page_with_redirect | |
72 | wiki = Wiki.find(1) |
|
72 | wiki = Wiki.find(1) | |
73 | WikiRedirect.create!(:wiki => wiki, :title => 'Old_title', :redirects_to => 'Another_page') |
|
73 | WikiRedirect.create!(:wiki => wiki, :title => 'Old_title', :redirects_to => 'Another_page') | |
@@ -76,26 +76,26 class WikiTest < ActiveSupport::TestCase | |||||
76 | assert_equal 'Another_page', page.title |
|
76 | assert_equal 'Another_page', page.title | |
77 | assert_equal true, wiki.page_found_with_redirect? |
|
77 | assert_equal true, wiki.page_found_with_redirect? | |
78 | end |
|
78 | end | |
79 |
|
79 | |||
80 | def test_titleize |
|
80 | def test_titleize | |
81 | assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES') |
|
81 | assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES') | |
82 | assert_equal 'テスト', Wiki.titleize('テスト') |
|
82 | assert_equal 'テスト', Wiki.titleize('テスト') | |
83 | end |
|
83 | end | |
84 |
|
84 | |||
85 | context "#sidebar" do |
|
85 | context "#sidebar" do | |
86 | setup do |
|
86 | setup do | |
87 | @wiki = Wiki.find(1) |
|
87 | @wiki = Wiki.find(1) | |
88 | end |
|
88 | end | |
89 |
|
89 | |||
90 | should "return nil if undefined" do |
|
90 | should "return nil if undefined" do | |
91 | assert_nil @wiki.sidebar |
|
91 | assert_nil @wiki.sidebar | |
92 | end |
|
92 | end | |
93 |
|
93 | |||
94 | should "return a WikiPage if defined" do |
|
94 | should "return a WikiPage if defined" do | |
95 | page = @wiki.pages.new(:title => 'Sidebar') |
|
95 | page = @wiki.pages.new(:title => 'Sidebar') | |
96 | page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar') |
|
96 | page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar') | |
97 | page.save! |
|
97 | page.save! | |
98 |
|
98 | |||
99 | assert_kind_of WikiPage, @wiki.sidebar |
|
99 | assert_kind_of WikiPage, @wiki.sidebar | |
100 | assert_equal 'Sidebar', @wiki.sidebar.title |
|
100 | assert_equal 'Sidebar', @wiki.sidebar.title | |
101 | end |
|
101 | end |
General Comments 0
You need to be logged in to leave comments.
Login now