@@ -5,12 +5,12 | |||||
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 |
# |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 |
# |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
@@ -24,45 +24,45 class WikiPageTest < ActiveSupport::TestCase | |||||
24 | @wiki = Wiki.find(1) |
|
24 | @wiki = Wiki.find(1) | |
25 | @page = @wiki.pages.first |
|
25 | @page = @wiki.pages.first | |
26 | end |
|
26 | end | |
27 |
|
27 | |||
28 | def test_create |
|
28 | def test_create | |
29 | page = WikiPage.new(:wiki => @wiki) |
|
29 | page = WikiPage.new(:wiki => @wiki) | |
30 | assert !page.save |
|
30 | assert !page.save | |
31 | assert_equal 1, page.errors.count |
|
31 | assert_equal 1, page.errors.count | |
32 |
|
32 | |||
33 | page.title = "Page" |
|
33 | page.title = "Page" | |
34 | assert page.save |
|
34 | assert page.save | |
35 | page.reload |
|
35 | page.reload | |
36 | assert !page.protected? |
|
36 | assert !page.protected? | |
37 |
|
37 | |||
38 | @wiki.reload |
|
38 | @wiki.reload | |
39 | assert @wiki.pages.include?(page) |
|
39 | assert @wiki.pages.include?(page) | |
40 | end |
|
40 | end | |
41 |
|
41 | |||
42 | def test_sidebar_should_be_protected_by_default |
|
42 | def test_sidebar_should_be_protected_by_default | |
43 | page = @wiki.find_or_new_page('sidebar') |
|
43 | page = @wiki.find_or_new_page('sidebar') | |
44 | assert page.new_record? |
|
44 | assert page.new_record? | |
45 | assert page.protected? |
|
45 | assert page.protected? | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | def test_find_or_new_page |
|
48 | def test_find_or_new_page | |
49 | page = @wiki.find_or_new_page("CookBook documentation") |
|
49 | page = @wiki.find_or_new_page("CookBook documentation") | |
50 | assert_kind_of WikiPage, page |
|
50 | assert_kind_of WikiPage, page | |
51 | assert !page.new_record? |
|
51 | assert !page.new_record? | |
52 |
|
52 | |||
53 | page = @wiki.find_or_new_page("Non existing page") |
|
53 | page = @wiki.find_or_new_page("Non existing page") | |
54 | assert_kind_of WikiPage, page |
|
54 | assert_kind_of WikiPage, page | |
55 | assert page.new_record? |
|
55 | assert page.new_record? | |
56 | end |
|
56 | end | |
57 |
|
57 | |||
58 | def test_parent_title |
|
58 | def test_parent_title | |
59 | page = WikiPage.find_by_title('Another_page') |
|
59 | page = WikiPage.find_by_title('Another_page') | |
60 | assert_nil page.parent_title |
|
60 | assert_nil page.parent_title | |
61 |
|
61 | |||
62 | page = WikiPage.find_by_title('Page_with_an_inline_image') |
|
62 | page = WikiPage.find_by_title('Page_with_an_inline_image') | |
63 | assert_equal 'CookBook documentation', page.parent_title |
|
63 | assert_equal 'CookBook documentation', page.parent_title | |
64 | end |
|
64 | end | |
65 |
|
65 | |||
66 | def test_assign_parent |
|
66 | def test_assign_parent | |
67 | page = WikiPage.find_by_title('Another_page') |
|
67 | page = WikiPage.find_by_title('Another_page') | |
68 | page.parent_title = 'CookBook documentation' |
|
68 | page.parent_title = 'CookBook documentation' | |
@@ -70,7 +70,7 class WikiPageTest < ActiveSupport::TestCase | |||||
70 | page.reload |
|
70 | page.reload | |
71 | assert_equal WikiPage.find_by_title('CookBook_documentation'), page.parent |
|
71 | assert_equal WikiPage.find_by_title('CookBook_documentation'), page.parent | |
72 | end |
|
72 | end | |
73 |
|
73 | |||
74 | def test_unassign_parent |
|
74 | def test_unassign_parent | |
75 | page = WikiPage.find_by_title('Page_with_an_inline_image') |
|
75 | page = WikiPage.find_by_title('Page_with_an_inline_image') | |
76 | page.parent_title = '' |
|
76 | page.parent_title = '' | |
@@ -78,10 +78,10 class WikiPageTest < ActiveSupport::TestCase | |||||
78 | page.reload |
|
78 | page.reload | |
79 | assert_nil page.parent |
|
79 | assert_nil page.parent | |
80 | end |
|
80 | end | |
81 |
|
81 | |||
82 | def test_parent_validation |
|
82 | def test_parent_validation | |
83 | page = WikiPage.find_by_title('CookBook_documentation') |
|
83 | page = WikiPage.find_by_title('CookBook_documentation') | |
84 |
|
84 | |||
85 | # A page that doesn't exist |
|
85 | # A page that doesn't exist | |
86 | page.parent_title = 'Unknown title' |
|
86 | page.parent_title = 'Unknown title' | |
87 | assert !page.save |
|
87 | assert !page.save | |
@@ -98,7 +98,7 class WikiPageTest < ActiveSupport::TestCase | |||||
98 | page.parent_title = 'Another_page' |
|
98 | page.parent_title = 'Another_page' | |
99 | assert page.save |
|
99 | assert page.save | |
100 | end |
|
100 | end | |
101 |
|
101 | |||
102 | def test_destroy |
|
102 | def test_destroy | |
103 | page = WikiPage.find(1) |
|
103 | page = WikiPage.find(1) | |
104 | page.destroy |
|
104 | page.destroy | |
@@ -107,21 +107,21 class WikiPageTest < ActiveSupport::TestCase | |||||
107 | assert WikiContent.find_all_by_page_id(1).empty? |
|
107 | assert WikiContent.find_all_by_page_id(1).empty? | |
108 | assert WikiContent.versioned_class.find_all_by_page_id(1).empty? |
|
108 | assert WikiContent.versioned_class.find_all_by_page_id(1).empty? | |
109 | end |
|
109 | end | |
110 |
|
110 | |||
111 | def test_destroy_should_not_nullify_children |
|
111 | def test_destroy_should_not_nullify_children | |
112 | page = WikiPage.find(2) |
|
112 | page = WikiPage.find(2) | |
113 | child_ids = page.child_ids |
|
113 | child_ids = page.child_ids | |
114 | assert child_ids.any? |
|
114 | assert child_ids.any? | |
115 | page.destroy |
|
115 | page.destroy | |
116 | assert_nil WikiPage.find_by_id(2) |
|
116 | assert_nil WikiPage.find_by_id(2) | |
117 |
|
117 | |||
118 | children = WikiPage.find_all_by_id(child_ids) |
|
118 | children = WikiPage.find_all_by_id(child_ids) | |
119 | assert_equal child_ids.size, children.size |
|
119 | assert_equal child_ids.size, children.size | |
120 | children.each do |child| |
|
120 | children.each do |child| | |
121 | assert_nil child.parent_id |
|
121 | assert_nil child.parent_id | |
122 | end |
|
122 | end | |
123 | end |
|
123 | end | |
124 |
|
124 | |||
125 | def test_updated_on_eager_load |
|
125 | def test_updated_on_eager_load | |
126 | page = WikiPage.with_updated_on.first |
|
126 | page = WikiPage.with_updated_on.first | |
127 | assert page.is_a?(WikiPage) |
|
127 | assert page.is_a?(WikiPage) |
General Comments 0
You need to be logged in to leave comments.
Login now