@@ -1,543 +1,553 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
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. | |
17 |
|
17 | |||
18 | require File.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 | require 'wiki_controller' |
|
19 | require 'wiki_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class WikiController; def rescue_action(e) raise e end; end |
|
22 | class WikiController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class WikiControllerTest < ActionController::TestCase |
|
24 | class WikiControllerTest < ActionController::TestCase | |
25 | fixtures :projects, :users, :roles, :members, :member_roles, |
|
25 | fixtures :projects, :users, :roles, :members, :member_roles, | |
26 | :enabled_modules, :wikis, :wiki_pages, :wiki_contents, |
|
26 | :enabled_modules, :wikis, :wiki_pages, :wiki_contents, | |
27 | :wiki_content_versions, :attachments |
|
27 | :wiki_content_versions, :attachments | |
28 |
|
28 | |||
29 | def setup |
|
29 | def setup | |
30 | @controller = WikiController.new |
|
30 | @controller = WikiController.new | |
31 | @request = ActionController::TestRequest.new |
|
31 | @request = ActionController::TestRequest.new | |
32 | @response = ActionController::TestResponse.new |
|
32 | @response = ActionController::TestResponse.new | |
33 | User.current = nil |
|
33 | User.current = nil | |
34 | end |
|
34 | end | |
35 |
|
35 | |||
36 | def test_show_start_page |
|
36 | def test_show_start_page | |
37 | get :show, :project_id => 'ecookbook' |
|
37 | get :show, :project_id => 'ecookbook' | |
38 | assert_response :success |
|
38 | assert_response :success | |
39 | assert_template 'show' |
|
39 | assert_template 'show' | |
40 | assert_tag :tag => 'h1', :content => /CookBook documentation/ |
|
40 | assert_tag :tag => 'h1', :content => /CookBook documentation/ | |
41 |
|
41 | |||
42 | # child_pages macro |
|
42 | # child_pages macro | |
43 | assert_tag :ul, :attributes => { :class => 'pages-hierarchy' }, |
|
43 | assert_tag :ul, :attributes => { :class => 'pages-hierarchy' }, | |
44 | :child => { :tag => 'li', |
|
44 | :child => { :tag => 'li', | |
45 | :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' }, |
|
45 | :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' }, | |
46 | :content => 'Page with an inline image' } } |
|
46 | :content => 'Page with an inline image' } } | |
47 | end |
|
47 | end | |
48 |
|
48 | |||
49 | def test_show_page_with_name |
|
49 | def test_show_page_with_name | |
50 | get :show, :project_id => 1, :id => 'Another_page' |
|
50 | get :show, :project_id => 1, :id => 'Another_page' | |
51 | assert_response :success |
|
51 | assert_response :success | |
52 | assert_template 'show' |
|
52 | assert_template 'show' | |
53 | assert_tag :tag => 'h1', :content => /Another page/ |
|
53 | assert_tag :tag => 'h1', :content => /Another page/ | |
54 | # Included page with an inline image |
|
54 | # Included page with an inline image | |
55 | assert_tag :tag => 'p', :content => /This is an inline image/ |
|
55 | assert_tag :tag => 'p', :content => /This is an inline image/ | |
56 | assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3', |
|
56 | assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3', | |
57 | :alt => 'This is a logo' } |
|
57 | :alt => 'This is a logo' } | |
58 | end |
|
58 | end | |
59 |
|
59 | |||
60 | def test_show_redirected_page |
|
60 | def test_show_redirected_page | |
61 | WikiRedirect.create!(:wiki_id => 1, :title => 'Old_title', :redirects_to => 'Another_page') |
|
61 | WikiRedirect.create!(:wiki_id => 1, :title => 'Old_title', :redirects_to => 'Another_page') | |
62 |
|
62 | |||
63 | get :show, :project_id => 'ecookbook', :id => 'Old_title' |
|
63 | get :show, :project_id => 'ecookbook', :id => 'Old_title' | |
64 | assert_redirected_to '/projects/ecookbook/wiki/Another_page' |
|
64 | assert_redirected_to '/projects/ecookbook/wiki/Another_page' | |
65 | end |
|
65 | end | |
66 |
|
66 | |||
67 | def test_show_with_sidebar |
|
67 | def test_show_with_sidebar | |
68 | page = Project.find(1).wiki.pages.new(:title => 'Sidebar') |
|
68 | page = Project.find(1).wiki.pages.new(:title => 'Sidebar') | |
69 | page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar') |
|
69 | page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar') | |
70 | page.save! |
|
70 | page.save! | |
71 |
|
71 | |||
72 | get :show, :project_id => 1, :id => 'Another_page' |
|
72 | get :show, :project_id => 1, :id => 'Another_page' | |
73 | assert_response :success |
|
73 | assert_response :success | |
74 | assert_tag :tag => 'div', :attributes => {:id => 'sidebar'}, |
|
74 | assert_tag :tag => 'div', :attributes => {:id => 'sidebar'}, | |
75 | :content => /Side bar content for test_show_with_sidebar/ |
|
75 | :content => /Side bar content for test_show_with_sidebar/ | |
76 | end |
|
76 | end | |
77 |
|
77 | |||
78 | def test_show_unexistent_page_without_edit_right |
|
78 | def test_show_unexistent_page_without_edit_right | |
79 | get :show, :project_id => 1, :id => 'Unexistent page' |
|
79 | get :show, :project_id => 1, :id => 'Unexistent page' | |
80 | assert_response 404 |
|
80 | assert_response 404 | |
81 | end |
|
81 | end | |
82 |
|
82 | |||
83 | def test_show_unexistent_page_with_edit_right |
|
83 | def test_show_unexistent_page_with_edit_right | |
84 | @request.session[:user_id] = 2 |
|
84 | @request.session[:user_id] = 2 | |
85 | get :show, :project_id => 1, :id => 'Unexistent page' |
|
85 | get :show, :project_id => 1, :id => 'Unexistent page' | |
86 | assert_response :success |
|
86 | assert_response :success | |
87 | assert_template 'edit' |
|
87 | assert_template 'edit' | |
88 | end |
|
88 | end | |
89 |
|
89 | |||
90 | def test_create_page |
|
90 | def test_create_page | |
91 | @request.session[:user_id] = 2 |
|
91 | @request.session[:user_id] = 2 | |
92 | put :update, :project_id => 1, |
|
92 | put :update, :project_id => 1, | |
93 | :id => 'New page', |
|
93 | :id => 'New page', | |
94 | :content => {:comments => 'Created the page', |
|
94 | :content => {:comments => 'Created the page', | |
95 | :text => "h1. New page\n\nThis is a new page", |
|
95 | :text => "h1. New page\n\nThis is a new page", | |
96 | :version => 0} |
|
96 | :version => 0} | |
97 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'New_page' |
|
97 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'New_page' | |
98 | page = Project.find(1).wiki.find_page('New page') |
|
98 | page = Project.find(1).wiki.find_page('New page') | |
99 | assert !page.new_record? |
|
99 | assert !page.new_record? | |
100 | assert_not_nil page.content |
|
100 | assert_not_nil page.content | |
101 | assert_equal 'Created the page', page.content.comments |
|
101 | assert_equal 'Created the page', page.content.comments | |
102 | end |
|
102 | end | |
103 |
|
103 | |||
104 | def test_create_page_with_attachments |
|
104 | def test_create_page_with_attachments | |
105 | @request.session[:user_id] = 2 |
|
105 | @request.session[:user_id] = 2 | |
106 | assert_difference 'WikiPage.count' do |
|
106 | assert_difference 'WikiPage.count' do | |
107 | assert_difference 'Attachment.count' do |
|
107 | assert_difference 'Attachment.count' do | |
108 | put :update, :project_id => 1, |
|
108 | put :update, :project_id => 1, | |
109 | :id => 'New page', |
|
109 | :id => 'New page', | |
110 | :content => {:comments => 'Created the page', |
|
110 | :content => {:comments => 'Created the page', | |
111 | :text => "h1. New page\n\nThis is a new page", |
|
111 | :text => "h1. New page\n\nThis is a new page", | |
112 | :version => 0}, |
|
112 | :version => 0}, | |
113 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} |
|
113 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
114 | end |
|
114 | end | |
115 | end |
|
115 | end | |
116 | page = Project.find(1).wiki.find_page('New page') |
|
116 | page = Project.find(1).wiki.find_page('New page') | |
117 | assert_equal 1, page.attachments.count |
|
117 | assert_equal 1, page.attachments.count | |
118 | assert_equal 'testfile.txt', page.attachments.first.filename |
|
118 | assert_equal 'testfile.txt', page.attachments.first.filename | |
119 | end |
|
119 | end | |
120 |
|
120 | |||
121 | def test_update_page |
|
121 | def test_update_page | |
122 | @request.session[:user_id] = 2 |
|
122 | @request.session[:user_id] = 2 | |
123 | assert_no_difference 'WikiPage.count' do |
|
123 | assert_no_difference 'WikiPage.count' do | |
124 | assert_no_difference 'WikiContent.count' do |
|
124 | assert_no_difference 'WikiContent.count' do | |
125 | assert_difference 'WikiContent::Version.count' do |
|
125 | assert_difference 'WikiContent::Version.count' do | |
126 | put :update, :project_id => 1, |
|
126 | put :update, :project_id => 1, | |
127 | :id => 'Another_page', |
|
127 | :id => 'Another_page', | |
128 | :content => { |
|
128 | :content => { | |
129 | :comments => "my comments", |
|
129 | :comments => "my comments", | |
130 | :text => "edited", |
|
130 | :text => "edited", | |
131 | :version => 1 |
|
131 | :version => 1 | |
132 | } |
|
132 | } | |
133 | end |
|
133 | end | |
134 | end |
|
134 | end | |
135 | end |
|
135 | end | |
136 | assert_redirected_to '/projects/ecookbook/wiki/Another_page' |
|
136 | assert_redirected_to '/projects/ecookbook/wiki/Another_page' | |
137 |
|
137 | |||
138 | page = Wiki.find(1).pages.find_by_title('Another_page') |
|
138 | page = Wiki.find(1).pages.find_by_title('Another_page') | |
139 | assert_equal "edited", page.content.text |
|
139 | assert_equal "edited", page.content.text | |
140 | assert_equal 2, page.content.version |
|
140 | assert_equal 2, page.content.version | |
141 | assert_equal "my comments", page.content.comments |
|
141 | assert_equal "my comments", page.content.comments | |
142 | end |
|
142 | end | |
143 |
|
143 | |||
144 | def test_update_page_with_failure |
|
144 | def test_update_page_with_failure | |
145 | @request.session[:user_id] = 2 |
|
145 | @request.session[:user_id] = 2 | |
146 | assert_no_difference 'WikiPage.count' do |
|
146 | assert_no_difference 'WikiPage.count' do | |
147 | assert_no_difference 'WikiContent.count' do |
|
147 | assert_no_difference 'WikiContent.count' do | |
148 | assert_no_difference 'WikiContent::Version.count' do |
|
148 | assert_no_difference 'WikiContent::Version.count' do | |
149 | put :update, :project_id => 1, |
|
149 | put :update, :project_id => 1, | |
150 | :id => 'Another_page', |
|
150 | :id => 'Another_page', | |
151 | :content => { |
|
151 | :content => { | |
152 | :comments => 'a' * 300, # failure here, comment is too long |
|
152 | :comments => 'a' * 300, # failure here, comment is too long | |
153 | :text => 'edited', |
|
153 | :text => 'edited', | |
154 | :version => 1 |
|
154 | :version => 1 | |
155 | } |
|
155 | } | |
156 | end |
|
156 | end | |
157 | end |
|
157 | end | |
158 | end |
|
158 | end | |
159 | assert_response :success |
|
159 | assert_response :success | |
160 | assert_template 'edit' |
|
160 | assert_template 'edit' | |
161 |
|
161 | |||
162 | assert_error_tag :descendant => {:content => /Comment is too long/} |
|
162 | assert_error_tag :descendant => {:content => /Comment is too long/} | |
163 | assert_tag :tag => 'textarea', :attributes => {:id => 'content_text'}, :content => 'edited' |
|
163 | assert_tag :tag => 'textarea', :attributes => {:id => 'content_text'}, :content => 'edited' | |
164 | assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'} |
|
164 | assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'} | |
165 | end |
|
165 | end | |
166 |
|
166 | |||
167 | def test_update_stale_page_should_not_raise_an_error |
|
167 | def test_update_stale_page_should_not_raise_an_error | |
168 | @request.session[:user_id] = 2 |
|
168 | @request.session[:user_id] = 2 | |
169 | c = Wiki.find(1).find_page('Another_page').content |
|
169 | c = Wiki.find(1).find_page('Another_page').content | |
170 | c.text = 'Previous text' |
|
170 | c.text = 'Previous text' | |
171 | c.save! |
|
171 | c.save! | |
172 | assert_equal 2, c.version |
|
172 | assert_equal 2, c.version | |
173 |
|
173 | |||
174 | assert_no_difference 'WikiPage.count' do |
|
174 | assert_no_difference 'WikiPage.count' do | |
175 | assert_no_difference 'WikiContent.count' do |
|
175 | assert_no_difference 'WikiContent.count' do | |
176 | assert_no_difference 'WikiContent::Version.count' do |
|
176 | assert_no_difference 'WikiContent::Version.count' do | |
177 | put :update, :project_id => 1, |
|
177 | put :update, :project_id => 1, | |
178 | :id => 'Another_page', |
|
178 | :id => 'Another_page', | |
179 | :content => { |
|
179 | :content => { | |
180 | :comments => 'My comments', |
|
180 | :comments => 'My comments', | |
181 | :text => 'Text should not be lost', |
|
181 | :text => 'Text should not be lost', | |
182 | :version => 1 |
|
182 | :version => 1 | |
183 | } |
|
183 | } | |
184 | end |
|
184 | end | |
185 | end |
|
185 | end | |
186 | end |
|
186 | end | |
187 | assert_response :success |
|
187 | assert_response :success | |
188 | assert_template 'edit' |
|
188 | assert_template 'edit' | |
189 | assert_tag :div, |
|
189 | assert_tag :div, | |
190 | :attributes => { :class => /error/ }, |
|
190 | :attributes => { :class => /error/ }, | |
191 | :content => /Data has been updated by another user/ |
|
191 | :content => /Data has been updated by another user/ | |
192 | assert_tag 'textarea', |
|
192 | assert_tag 'textarea', | |
193 | :attributes => { :name => 'content[text]' }, |
|
193 | :attributes => { :name => 'content[text]' }, | |
194 | :content => /Text should not be lost/ |
|
194 | :content => /Text should not be lost/ | |
195 | assert_tag 'input', |
|
195 | assert_tag 'input', | |
196 | :attributes => { :name => 'content[comments]', :value => 'My comments' } |
|
196 | :attributes => { :name => 'content[comments]', :value => 'My comments' } | |
197 |
|
197 | |||
198 | c.reload |
|
198 | c.reload | |
199 | assert_equal 'Previous text', c.text |
|
199 | assert_equal 'Previous text', c.text | |
200 | assert_equal 2, c.version |
|
200 | assert_equal 2, c.version | |
201 | end |
|
201 | end | |
202 |
|
202 | |||
203 | def test_preview |
|
203 | def test_preview | |
204 | @request.session[:user_id] = 2 |
|
204 | @request.session[:user_id] = 2 | |
205 | xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation', |
|
205 | xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation', | |
206 | :content => { :comments => '', |
|
206 | :content => { :comments => '', | |
207 | :text => 'this is a *previewed text*', |
|
207 | :text => 'this is a *previewed text*', | |
208 | :version => 3 } |
|
208 | :version => 3 } | |
209 | assert_response :success |
|
209 | assert_response :success | |
210 | assert_template 'common/_preview' |
|
210 | assert_template 'common/_preview' | |
211 | assert_tag :tag => 'strong', :content => /previewed text/ |
|
211 | assert_tag :tag => 'strong', :content => /previewed text/ | |
212 | end |
|
212 | end | |
213 |
|
213 | |||
214 | def test_preview_new_page |
|
214 | def test_preview_new_page | |
215 | @request.session[:user_id] = 2 |
|
215 | @request.session[:user_id] = 2 | |
216 | xhr :post, :preview, :project_id => 1, :id => 'New page', |
|
216 | xhr :post, :preview, :project_id => 1, :id => 'New page', | |
217 | :content => { :text => 'h1. New page', |
|
217 | :content => { :text => 'h1. New page', | |
218 | :comments => '', |
|
218 | :comments => '', | |
219 | :version => 0 } |
|
219 | :version => 0 } | |
220 | assert_response :success |
|
220 | assert_response :success | |
221 | assert_template 'common/_preview' |
|
221 | assert_template 'common/_preview' | |
222 | assert_tag :tag => 'h1', :content => /New page/ |
|
222 | assert_tag :tag => 'h1', :content => /New page/ | |
223 | end |
|
223 | end | |
224 |
|
224 | |||
225 | def test_history |
|
225 | def test_history | |
226 | get :history, :project_id => 1, :id => 'CookBook_documentation' |
|
226 | get :history, :project_id => 1, :id => 'CookBook_documentation' | |
227 | assert_response :success |
|
227 | assert_response :success | |
228 | assert_template 'history' |
|
228 | assert_template 'history' | |
229 | assert_not_nil assigns(:versions) |
|
229 | assert_not_nil assigns(:versions) | |
230 | assert_equal 3, assigns(:versions).size |
|
230 | assert_equal 3, assigns(:versions).size | |
231 | assert_select "input[type=submit][name=commit]" |
|
231 | assert_select "input[type=submit][name=commit]" | |
232 | end |
|
232 | end | |
233 |
|
233 | |||
234 | def test_history_with_one_version |
|
234 | def test_history_with_one_version | |
235 | get :history, :project_id => 1, :id => 'Another_page' |
|
235 | get :history, :project_id => 1, :id => 'Another_page' | |
236 | assert_response :success |
|
236 | assert_response :success | |
237 | assert_template 'history' |
|
237 | assert_template 'history' | |
238 | assert_not_nil assigns(:versions) |
|
238 | assert_not_nil assigns(:versions) | |
239 | assert_equal 1, assigns(:versions).size |
|
239 | assert_equal 1, assigns(:versions).size | |
240 | assert_select "input[type=submit][name=commit]", false |
|
240 | assert_select "input[type=submit][name=commit]", false | |
241 | end |
|
241 | end | |
242 |
|
242 | |||
243 | def test_diff |
|
243 | def test_diff | |
244 | get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => 2, :version_from => 1 |
|
244 | get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => 2, :version_from => 1 | |
245 | assert_response :success |
|
245 | assert_response :success | |
246 | assert_template 'diff' |
|
246 | assert_template 'diff' | |
247 | assert_tag :tag => 'span', :attributes => { :class => 'diff_in'}, |
|
247 | assert_tag :tag => 'span', :attributes => { :class => 'diff_in'}, | |
248 | :content => /updated/ |
|
248 | :content => /updated/ | |
249 | end |
|
249 | end | |
250 |
|
250 | |||
251 | def test_annotate |
|
251 | def test_annotate | |
252 | get :annotate, :project_id => 1, :id => 'CookBook_documentation', :version => 2 |
|
252 | get :annotate, :project_id => 1, :id => 'CookBook_documentation', :version => 2 | |
253 | assert_response :success |
|
253 | assert_response :success | |
254 | assert_template 'annotate' |
|
254 | assert_template 'annotate' | |
255 |
|
255 | |||
256 | # Line 1 |
|
256 | # Line 1 | |
257 | assert_tag :tag => 'tr', :child => { |
|
257 | assert_tag :tag => 'tr', :child => { | |
258 | :tag => 'th', :attributes => {:class => 'line-num'}, :content => '1', :sibling => { |
|
258 | :tag => 'th', :attributes => {:class => 'line-num'}, :content => '1', :sibling => { | |
259 | :tag => 'td', :attributes => {:class => 'author'}, :content => /John Smith/, :sibling => { |
|
259 | :tag => 'td', :attributes => {:class => 'author'}, :content => /John Smith/, :sibling => { | |
260 | :tag => 'td', :content => /h1\. CookBook documentation/ |
|
260 | :tag => 'td', :content => /h1\. CookBook documentation/ | |
261 | } |
|
261 | } | |
262 | } |
|
262 | } | |
263 | } |
|
263 | } | |
264 |
|
264 | |||
265 | # Line 5 |
|
265 | # Line 5 | |
266 | assert_tag :tag => 'tr', :child => { |
|
266 | assert_tag :tag => 'tr', :child => { | |
267 | :tag => 'th', :attributes => {:class => 'line-num'}, :content => '5', :sibling => { |
|
267 | :tag => 'th', :attributes => {:class => 'line-num'}, :content => '5', :sibling => { | |
268 | :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/, :sibling => { |
|
268 | :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/, :sibling => { | |
269 | :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ |
|
269 | :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ | |
270 | } |
|
270 | } | |
271 | } |
|
271 | } | |
272 | } |
|
272 | } | |
273 | end |
|
273 | end | |
274 |
|
274 | |||
275 | def test_get_rename |
|
275 | def test_get_rename | |
276 | @request.session[:user_id] = 2 |
|
276 | @request.session[:user_id] = 2 | |
277 | get :rename, :project_id => 1, :id => 'Another_page' |
|
277 | get :rename, :project_id => 1, :id => 'Another_page' | |
278 | assert_response :success |
|
278 | assert_response :success | |
279 | assert_template 'rename' |
|
279 | assert_template 'rename' | |
280 | assert_tag 'option', |
|
280 | assert_tag 'option', | |
281 | :attributes => {:value => ''}, |
|
281 | :attributes => {:value => ''}, | |
282 | :content => '', |
|
282 | :content => '', | |
283 | :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}} |
|
283 | :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}} | |
284 | assert_no_tag 'option', |
|
284 | assert_no_tag 'option', | |
285 | :attributes => {:selected => 'selected'}, |
|
285 | :attributes => {:selected => 'selected'}, | |
286 | :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}} |
|
286 | :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}} | |
287 | end |
|
287 | end | |
288 |
|
288 | |||
289 | def test_get_rename_child_page |
|
289 | def test_get_rename_child_page | |
290 | @request.session[:user_id] = 2 |
|
290 | @request.session[:user_id] = 2 | |
291 | get :rename, :project_id => 1, :id => 'Child_1' |
|
291 | get :rename, :project_id => 1, :id => 'Child_1' | |
292 | assert_response :success |
|
292 | assert_response :success | |
293 | assert_template 'rename' |
|
293 | assert_template 'rename' | |
294 | assert_tag 'option', |
|
294 | assert_tag 'option', | |
295 | :attributes => {:value => ''}, |
|
295 | :attributes => {:value => ''}, | |
296 | :content => '', |
|
296 | :content => '', | |
297 | :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}} |
|
297 | :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}} | |
298 | assert_tag 'option', |
|
298 | assert_tag 'option', | |
299 | :attributes => {:value => '2', :selected => 'selected'}, |
|
299 | :attributes => {:value => '2', :selected => 'selected'}, | |
300 | :content => /Another page/, |
|
300 | :content => /Another page/, | |
301 | :parent => { |
|
301 | :parent => { | |
302 | :tag => 'select', |
|
302 | :tag => 'select', | |
303 | :attributes => {:name => 'wiki_page[parent_id]'} |
|
303 | :attributes => {:name => 'wiki_page[parent_id]'} | |
304 | } |
|
304 | } | |
305 | end |
|
305 | end | |
306 |
|
306 | |||
307 | def test_rename_with_redirect |
|
307 | def test_rename_with_redirect | |
308 | @request.session[:user_id] = 2 |
|
308 | @request.session[:user_id] = 2 | |
309 | post :rename, :project_id => 1, :id => 'Another_page', |
|
309 | post :rename, :project_id => 1, :id => 'Another_page', | |
310 | :wiki_page => { :title => 'Another renamed page', |
|
310 | :wiki_page => { :title => 'Another renamed page', | |
311 | :redirect_existing_links => 1 } |
|
311 | :redirect_existing_links => 1 } | |
312 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page' |
|
312 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page' | |
313 | wiki = Project.find(1).wiki |
|
313 | wiki = Project.find(1).wiki | |
314 | # Check redirects |
|
314 | # Check redirects | |
315 | assert_not_nil wiki.find_page('Another page') |
|
315 | assert_not_nil wiki.find_page('Another page') | |
316 | assert_nil wiki.find_page('Another page', :with_redirect => false) |
|
316 | assert_nil wiki.find_page('Another page', :with_redirect => false) | |
317 | end |
|
317 | end | |
318 |
|
318 | |||
319 | def test_rename_without_redirect |
|
319 | def test_rename_without_redirect | |
320 | @request.session[:user_id] = 2 |
|
320 | @request.session[:user_id] = 2 | |
321 | post :rename, :project_id => 1, :id => 'Another_page', |
|
321 | post :rename, :project_id => 1, :id => 'Another_page', | |
322 | :wiki_page => { :title => 'Another renamed page', |
|
322 | :wiki_page => { :title => 'Another renamed page', | |
323 | :redirect_existing_links => "0" } |
|
323 | :redirect_existing_links => "0" } | |
324 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page' |
|
324 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page' | |
325 | wiki = Project.find(1).wiki |
|
325 | wiki = Project.find(1).wiki | |
326 | # Check that there's no redirects |
|
326 | # Check that there's no redirects | |
327 | assert_nil wiki.find_page('Another page') |
|
327 | assert_nil wiki.find_page('Another page') | |
328 | end |
|
328 | end | |
329 |
|
329 | |||
330 | def test_rename_with_parent_assignment |
|
330 | def test_rename_with_parent_assignment | |
331 | @request.session[:user_id] = 2 |
|
331 | @request.session[:user_id] = 2 | |
332 | post :rename, :project_id => 1, :id => 'Another_page', |
|
332 | post :rename, :project_id => 1, :id => 'Another_page', | |
333 | :wiki_page => { :title => 'Another page', :redirect_existing_links => "0", :parent_id => '4' } |
|
333 | :wiki_page => { :title => 'Another page', :redirect_existing_links => "0", :parent_id => '4' } | |
334 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page' |
|
334 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page' | |
335 | assert_equal WikiPage.find(4), WikiPage.find_by_title('Another_page').parent |
|
335 | assert_equal WikiPage.find(4), WikiPage.find_by_title('Another_page').parent | |
336 | end |
|
336 | end | |
337 |
|
337 | |||
338 | def test_rename_with_parent_unassignment |
|
338 | def test_rename_with_parent_unassignment | |
339 | @request.session[:user_id] = 2 |
|
339 | @request.session[:user_id] = 2 | |
340 | post :rename, :project_id => 1, :id => 'Child_1', |
|
340 | post :rename, :project_id => 1, :id => 'Child_1', | |
341 | :wiki_page => { :title => 'Child 1', :redirect_existing_links => "0", :parent_id => '' } |
|
341 | :wiki_page => { :title => 'Child 1', :redirect_existing_links => "0", :parent_id => '' } | |
342 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Child_1' |
|
342 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Child_1' | |
343 | assert_nil WikiPage.find_by_title('Child_1').parent |
|
343 | assert_nil WikiPage.find_by_title('Child_1').parent | |
344 | end |
|
344 | end | |
345 |
|
345 | |||
346 | def test_destroy_child |
|
346 | def test_destroy_child | |
347 | @request.session[:user_id] = 2 |
|
347 | @request.session[:user_id] = 2 | |
348 | delete :destroy, :project_id => 1, :id => 'Child_1' |
|
348 | delete :destroy, :project_id => 1, :id => 'Child_1' | |
349 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
349 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |
350 | end |
|
350 | end | |
351 |
|
351 | |||
352 | def test_destroy_parent |
|
352 | def test_destroy_parent | |
353 | @request.session[:user_id] = 2 |
|
353 | @request.session[:user_id] = 2 | |
354 | assert_no_difference('WikiPage.count') do |
|
354 | assert_no_difference('WikiPage.count') do | |
355 | delete :destroy, :project_id => 1, :id => 'Another_page' |
|
355 | delete :destroy, :project_id => 1, :id => 'Another_page' | |
356 | end |
|
356 | end | |
357 | assert_response :success |
|
357 | assert_response :success | |
358 | assert_template 'destroy' |
|
358 | assert_template 'destroy' | |
359 | end |
|
359 | end | |
360 |
|
360 | |||
361 | def test_destroy_parent_with_nullify |
|
361 | def test_destroy_parent_with_nullify | |
362 | @request.session[:user_id] = 2 |
|
362 | @request.session[:user_id] = 2 | |
363 | assert_difference('WikiPage.count', -1) do |
|
363 | assert_difference('WikiPage.count', -1) do | |
364 | delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'nullify' |
|
364 | delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'nullify' | |
365 | end |
|
365 | end | |
366 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
366 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |
367 | assert_nil WikiPage.find_by_id(2) |
|
367 | assert_nil WikiPage.find_by_id(2) | |
368 | end |
|
368 | end | |
369 |
|
369 | |||
370 | def test_destroy_parent_with_cascade |
|
370 | def test_destroy_parent_with_cascade | |
371 | @request.session[:user_id] = 2 |
|
371 | @request.session[:user_id] = 2 | |
372 | assert_difference('WikiPage.count', -3) do |
|
372 | assert_difference('WikiPage.count', -3) do | |
373 | delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'destroy' |
|
373 | delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'destroy' | |
374 | end |
|
374 | end | |
375 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
375 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |
376 | assert_nil WikiPage.find_by_id(2) |
|
376 | assert_nil WikiPage.find_by_id(2) | |
377 | assert_nil WikiPage.find_by_id(5) |
|
377 | assert_nil WikiPage.find_by_id(5) | |
378 | end |
|
378 | end | |
379 |
|
379 | |||
380 | def test_destroy_parent_with_reassign |
|
380 | def test_destroy_parent_with_reassign | |
381 | @request.session[:user_id] = 2 |
|
381 | @request.session[:user_id] = 2 | |
382 | assert_difference('WikiPage.count', -1) do |
|
382 | assert_difference('WikiPage.count', -1) do | |
383 | delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'reassign', :reassign_to_id => 1 |
|
383 | delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'reassign', :reassign_to_id => 1 | |
384 | end |
|
384 | end | |
385 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
385 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |
386 | assert_nil WikiPage.find_by_id(2) |
|
386 | assert_nil WikiPage.find_by_id(2) | |
387 | assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent |
|
387 | assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent | |
388 | end |
|
388 | end | |
389 |
|
389 | |||
390 | def test_index |
|
390 | def test_index | |
391 | get :index, :project_id => 'ecookbook' |
|
391 | get :index, :project_id => 'ecookbook' | |
392 | assert_response :success |
|
392 | assert_response :success | |
393 | assert_template 'index' |
|
393 | assert_template 'index' | |
394 | pages = assigns(:pages) |
|
394 | pages = assigns(:pages) | |
395 | assert_not_nil pages |
|
395 | assert_not_nil pages | |
396 | assert_equal Project.find(1).wiki.pages.size, pages.size |
|
396 | assert_equal Project.find(1).wiki.pages.size, pages.size | |
397 | assert_equal pages.first.content.updated_on, pages.first.updated_on |
|
397 | assert_equal pages.first.content.updated_on, pages.first.updated_on | |
398 |
|
398 | |||
399 | assert_tag :ul, :attributes => { :class => 'pages-hierarchy' }, |
|
399 | assert_tag :ul, :attributes => { :class => 'pages-hierarchy' }, | |
400 | :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' }, |
|
400 | :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' }, | |
401 | :content => 'CookBook documentation' }, |
|
401 | :content => 'CookBook documentation' }, | |
402 | :child => { :tag => 'ul', |
|
402 | :child => { :tag => 'ul', | |
403 | :child => { :tag => 'li', |
|
403 | :child => { :tag => 'li', | |
404 | :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' }, |
|
404 | :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' }, | |
405 | :content => 'Page with an inline image' } } } }, |
|
405 | :content => 'Page with an inline image' } } } }, | |
406 | :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' }, |
|
406 | :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' }, | |
407 | :content => 'Another page' } } |
|
407 | :content => 'Another page' } } | |
408 | end |
|
408 | end | |
409 |
|
409 | |||
410 | def test_index_should_include_atom_link |
|
410 | def test_index_should_include_atom_link | |
411 | get :index, :project_id => 'ecookbook' |
|
411 | get :index, :project_id => 'ecookbook' | |
412 | assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'} |
|
412 | assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'} | |
413 | end |
|
413 | end | |
414 |
|
414 | |||
415 | context "GET :export" do |
|
415 | context "GET :export" do | |
416 | context "with an authorized user to export the wiki" do |
|
416 | context "with an authorized user to export the wiki" do | |
417 | setup do |
|
417 | setup do | |
418 | @request.session[:user_id] = 2 |
|
418 | @request.session[:user_id] = 2 | |
419 | get :export, :project_id => 'ecookbook' |
|
419 | get :export, :project_id => 'ecookbook' | |
420 | end |
|
420 | end | |
421 |
|
421 | |||
422 | should_respond_with :success |
|
422 | should_respond_with :success | |
423 | should_assign_to :pages |
|
423 | should_assign_to :pages | |
424 | should_respond_with_content_type "text/html" |
|
424 | should_respond_with_content_type "text/html" | |
425 | should "export all of the wiki pages to a single html file" do |
|
425 | should "export all of the wiki pages to a single html file" do | |
426 | assert_select "a[name=?]", "CookBook_documentation" |
|
426 | assert_select "a[name=?]", "CookBook_documentation" | |
427 | assert_select "a[name=?]", "Another_page" |
|
427 | assert_select "a[name=?]", "Another_page" | |
428 | assert_select "a[name=?]", "Page_with_an_inline_image" |
|
428 | assert_select "a[name=?]", "Page_with_an_inline_image" | |
429 | end |
|
429 | end | |
430 |
|
430 | |||
431 | end |
|
431 | end | |
432 |
|
432 | |||
433 | context "with an unauthorized user" do |
|
433 | context "with an unauthorized user" do | |
434 | setup do |
|
434 | setup do | |
435 | get :export, :project_id => 'ecookbook' |
|
435 | get :export, :project_id => 'ecookbook' | |
436 |
|
436 | |||
437 | should_respond_with :redirect |
|
437 | should_respond_with :redirect | |
438 | should_redirect_to('wiki index') { {:action => 'show', :project_id => @project, :id => nil} } |
|
438 | should_redirect_to('wiki index') { {:action => 'show', :project_id => @project, :id => nil} } | |
439 | end |
|
439 | end | |
440 | end |
|
440 | end | |
441 | end |
|
441 | end | |
442 |
|
442 | |||
443 | context "GET :date_index" do |
|
443 | context "GET :date_index" do | |
444 | setup do |
|
444 | setup do | |
445 | get :date_index, :project_id => 'ecookbook' |
|
445 | get :date_index, :project_id => 'ecookbook' | |
446 | end |
|
446 | end | |
447 |
|
447 | |||
448 | should_respond_with :success |
|
448 | should_respond_with :success | |
449 | should_assign_to :pages |
|
449 | should_assign_to :pages | |
450 | should_assign_to :pages_by_date |
|
450 | should_assign_to :pages_by_date | |
451 | should_render_template 'wiki/date_index' |
|
451 | should_render_template 'wiki/date_index' | |
452 |
|
452 | |||
453 | should "include atom link" do |
|
453 | should "include atom link" do | |
454 | assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'} |
|
454 | assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'} | |
455 | end |
|
455 | end | |
456 | end |
|
456 | end | |
457 |
|
457 | |||
458 | def test_not_found |
|
458 | def test_not_found | |
459 | get :show, :project_id => 999 |
|
459 | get :show, :project_id => 999 | |
460 | assert_response 404 |
|
460 | assert_response 404 | |
461 | end |
|
461 | end | |
462 |
|
462 | |||
463 | def test_protect_page |
|
463 | def test_protect_page | |
464 | page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page') |
|
464 | page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page') | |
465 | assert !page.protected? |
|
465 | assert !page.protected? | |
466 | @request.session[:user_id] = 2 |
|
466 | @request.session[:user_id] = 2 | |
467 | post :protect, :project_id => 1, :id => page.title, :protected => '1' |
|
467 | post :protect, :project_id => 1, :id => page.title, :protected => '1' | |
468 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page' |
|
468 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page' | |
469 | assert page.reload.protected? |
|
469 | assert page.reload.protected? | |
470 | end |
|
470 | end | |
471 |
|
471 | |||
472 | def test_unprotect_page |
|
472 | def test_unprotect_page | |
473 | page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation') |
|
473 | page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation') | |
474 | assert page.protected? |
|
474 | assert page.protected? | |
475 | @request.session[:user_id] = 2 |
|
475 | @request.session[:user_id] = 2 | |
476 | post :protect, :project_id => 1, :id => page.title, :protected => '0' |
|
476 | post :protect, :project_id => 1, :id => page.title, :protected => '0' | |
477 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'CookBook_documentation' |
|
477 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'CookBook_documentation' | |
478 | assert !page.reload.protected? |
|
478 | assert !page.reload.protected? | |
479 | end |
|
479 | end | |
480 |
|
480 | |||
481 | def test_show_page_with_edit_link |
|
481 | def test_show_page_with_edit_link | |
482 | @request.session[:user_id] = 2 |
|
482 | @request.session[:user_id] = 2 | |
483 | get :show, :project_id => 1 |
|
483 | get :show, :project_id => 1 | |
484 | assert_response :success |
|
484 | assert_response :success | |
485 | assert_template 'show' |
|
485 | assert_template 'show' | |
486 | assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } |
|
486 | assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } | |
487 | end |
|
487 | end | |
488 |
|
488 | |||
489 | def test_show_page_without_edit_link |
|
489 | def test_show_page_without_edit_link | |
490 | @request.session[:user_id] = 4 |
|
490 | @request.session[:user_id] = 4 | |
491 | get :show, :project_id => 1 |
|
491 | get :show, :project_id => 1 | |
492 | assert_response :success |
|
492 | assert_response :success | |
493 | assert_template 'show' |
|
493 | assert_template 'show' | |
494 | assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } |
|
494 | assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } | |
495 | end |
|
495 | end | |
496 |
|
496 | |||
|
497 | def test_show_pdf | |||
|
498 | @request.session[:user_id] = 2 | |||
|
499 | get :show, :project_id => 1, :format => 'pdf' | |||
|
500 | assert_response :success | |||
|
501 | assert_not_nil assigns(:page) | |||
|
502 | assert_equal 'application/pdf', @response.content_type | |||
|
503 | assert_equal 'attachment; filename="CookBook_documentation.pdf"', | |||
|
504 | @response.headers['Content-Disposition'] | |||
|
505 | end | |||
|
506 | ||||
497 | def test_show_html |
|
507 | def test_show_html | |
498 | @request.session[:user_id] = 2 |
|
508 | @request.session[:user_id] = 2 | |
499 | get :show, :project_id => 1, :format => 'html' |
|
509 | get :show, :project_id => 1, :format => 'html' | |
500 | assert_response :success |
|
510 | assert_response :success | |
501 | assert_not_nil assigns(:page) |
|
511 | assert_not_nil assigns(:page) | |
502 | assert_equal 'text/html', @response.content_type |
|
512 | assert_equal 'text/html', @response.content_type | |
503 | assert_equal 'attachment; filename="CookBook_documentation.html"', |
|
513 | assert_equal 'attachment; filename="CookBook_documentation.html"', | |
504 | @response.headers['Content-Disposition'] |
|
514 | @response.headers['Content-Disposition'] | |
505 | end |
|
515 | end | |
506 |
|
516 | |||
507 | def test_show_txt |
|
517 | def test_show_txt | |
508 | @request.session[:user_id] = 2 |
|
518 | @request.session[:user_id] = 2 | |
509 | get :show, :project_id => 1, :format => 'txt' |
|
519 | get :show, :project_id => 1, :format => 'txt' | |
510 | assert_response :success |
|
520 | assert_response :success | |
511 | assert_not_nil assigns(:page) |
|
521 | assert_not_nil assigns(:page) | |
512 | assert_equal 'text/plain', @response.content_type |
|
522 | assert_equal 'text/plain', @response.content_type | |
513 | assert_equal 'attachment; filename="CookBook_documentation.txt"', |
|
523 | assert_equal 'attachment; filename="CookBook_documentation.txt"', | |
514 | @response.headers['Content-Disposition'] |
|
524 | @response.headers['Content-Disposition'] | |
515 | end |
|
525 | end | |
516 |
|
526 | |||
517 | def test_edit_unprotected_page |
|
527 | def test_edit_unprotected_page | |
518 | # Non members can edit unprotected wiki pages |
|
528 | # Non members can edit unprotected wiki pages | |
519 | @request.session[:user_id] = 4 |
|
529 | @request.session[:user_id] = 4 | |
520 | get :edit, :project_id => 1, :id => 'Another_page' |
|
530 | get :edit, :project_id => 1, :id => 'Another_page' | |
521 | assert_response :success |
|
531 | assert_response :success | |
522 | assert_template 'edit' |
|
532 | assert_template 'edit' | |
523 | end |
|
533 | end | |
524 |
|
534 | |||
525 | def test_edit_protected_page_by_nonmember |
|
535 | def test_edit_protected_page_by_nonmember | |
526 | # Non members can't edit protected wiki pages |
|
536 | # Non members can't edit protected wiki pages | |
527 | @request.session[:user_id] = 4 |
|
537 | @request.session[:user_id] = 4 | |
528 | get :edit, :project_id => 1, :id => 'CookBook_documentation' |
|
538 | get :edit, :project_id => 1, :id => 'CookBook_documentation' | |
529 | assert_response 403 |
|
539 | assert_response 403 | |
530 | end |
|
540 | end | |
531 |
|
541 | |||
532 | def test_edit_protected_page_by_member |
|
542 | def test_edit_protected_page_by_member | |
533 | @request.session[:user_id] = 2 |
|
543 | @request.session[:user_id] = 2 | |
534 | get :edit, :project_id => 1, :id => 'CookBook_documentation' |
|
544 | get :edit, :project_id => 1, :id => 'CookBook_documentation' | |
535 | assert_response :success |
|
545 | assert_response :success | |
536 | assert_template 'edit' |
|
546 | assert_template 'edit' | |
537 | end |
|
547 | end | |
538 |
|
548 | |||
539 | def test_history_of_non_existing_page_should_return_404 |
|
549 | def test_history_of_non_existing_page_should_return_404 | |
540 | get :history, :project_id => 1, :id => 'Unknown_page' |
|
550 | get :history, :project_id => 1, :id => 'Unknown_page' | |
541 | assert_response 404 |
|
551 | assert_response 404 | |
542 | end |
|
552 | end | |
543 | end |
|
553 | end |
General Comments 0
You need to be logged in to leave comments.
Login now