@@ -1,35 +1,35 | |||||
1 | <h2><%= @page.pretty_title %></h2> |
|
1 | <h2><%= @page.pretty_title %></h2> | |
2 |
|
2 | |||
3 | <h3><%= l(:label_history) %></h3> |
|
3 | <h3><%= l(:label_history) %></h3> | |
4 |
|
4 | |||
5 | <% form_tag({:action => "diff"}, :method => :get) do %> |
|
5 | <% form_tag({:action => "diff"}, :method => :get) do %> | |
6 | <table class="list"> |
|
6 | <table class="list"> | |
7 | <thead><tr> |
|
7 | <thead><tr> | |
8 | <th>#</th> |
|
8 | <th>#</th> | |
9 | <th></th> |
|
9 | <th></th> | |
10 | <th></th> |
|
10 | <th></th> | |
11 | <th><%= l(:field_updated_on) %></th> |
|
11 | <th><%= l(:field_updated_on) %></th> | |
12 | <th><%= l(:field_author) %></th> |
|
12 | <th><%= l(:field_author) %></th> | |
13 | <th><%= l(:field_comments) %></th> |
|
13 | <th><%= l(:field_comments) %></th> | |
14 | <th></th> |
|
14 | <th></th> | |
15 | </tr></thead> |
|
15 | </tr></thead> | |
16 | <tbody> |
|
16 | <tbody> | |
17 | <% show_diff = @versions.size > 1 %> |
|
17 | <% show_diff = @versions.size > 1 %> | |
18 | <% line_num = 1 %> |
|
18 | <% line_num = 1 %> | |
19 | <% @versions.each do |ver| %> |
|
19 | <% @versions.each do |ver| %> | |
20 | <tr class="<%= cycle("odd", "even") %>"> |
|
20 | <tr class="<%= cycle("odd", "even") %>"> | |
21 | <td class="id"><%= link_to ver.version, :action => 'index', :page => @page.title, :version => ver.version %></td> |
|
21 | <td class="id"><%= link_to ver.version, :action => 'index', :page => @page.title, :version => ver.version %></td> | |
22 | <td class="checkbox"><%= radio_button_tag('version', ver.version, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('cbto-#{line_num+1}').checked=true;") if show_diff && (line_num < @versions.size) %></td> |
|
22 | <td class="checkbox"><%= radio_button_tag('version', ver.version, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('cbto-#{line_num+1}').checked=true;") if show_diff && (line_num < @versions.size) %></td> | |
23 | <td class="checkbox"><%= radio_button_tag('version_from', ver.version, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('cb-#{line_num}').checked==true || $('version_from').value > #{ver.version}) {$('cb-#{line_num-1}').checked=true;}") if show_diff && (line_num > 1) %></td> |
|
23 | <td class="checkbox"><%= radio_button_tag('version_from', ver.version, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('cb-#{line_num}').checked==true || $('version_from').value > #{ver.version}) {$('cb-#{line_num-1}').checked=true;}") if show_diff && (line_num > 1) %></td> | |
24 | <td align="center"><%= format_time(ver.updated_on) %></td> |
|
24 | <td align="center"><%= format_time(ver.updated_on) %></td> | |
25 | <td><em><%= ver.author ? ver.author.name : "anonyme" %></em></td> |
|
25 | <td><em><%= ver.author ? ver.author.name : "anonyme" %></em></td> | |
26 | <td><%=h ver.comments %></td> |
|
26 | <td><%=h ver.comments %></td> | |
27 | <td align="center"><%= link_to l(:button_annotate), :action => 'annotate', :page => @page.title, :version => ver.version %></td> |
|
27 | <td align="center"><%= link_to l(:button_annotate), :action => 'annotate', :page => @page.title, :version => ver.version %></td> | |
28 | </tr> |
|
28 | </tr> | |
29 | <% line_num += 1 %> |
|
29 | <% line_num += 1 %> | |
30 | <% end %> |
|
30 | <% end %> | |
31 | </tbody> |
|
31 | </tbody> | |
32 | </table> |
|
32 | </table> | |
33 | <%= submit_tag l(:label_view_diff), :class => 'small' %> |
|
33 | <%= submit_tag l(:label_view_diff), :class => 'small' if show_diff %> | |
34 | <span class="pagination"><%= pagination_links_full @version_pages, @version_count, :page_param => :p %></span> |
|
34 | <span class="pagination"><%= pagination_links_full @version_pages, @version_count, :page_param => :p %></span> | |
35 | <% end %> |
|
35 | <% end %> |
@@ -1,244 +1,254 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 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.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
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 < Test::Unit::TestCase |
|
24 | class WikiControllerTest < Test::Unit::TestCase | |
25 | fixtures :projects, :users, :roles, :members, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :attachments |
|
25 | fixtures :projects, :users, :roles, :members, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :attachments | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = WikiController.new |
|
28 | @controller = WikiController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | User.current = nil |
|
31 | User.current = nil | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def test_show_start_page |
|
34 | def test_show_start_page | |
35 | get :index, :id => 'ecookbook' |
|
35 | get :index, :id => 'ecookbook' | |
36 | assert_response :success |
|
36 | assert_response :success | |
37 | assert_template 'show' |
|
37 | assert_template 'show' | |
38 | assert_tag :tag => 'h1', :content => /CookBook documentation/ |
|
38 | assert_tag :tag => 'h1', :content => /CookBook documentation/ | |
39 |
|
39 | |||
40 | # child_pages macro |
|
40 | # child_pages macro | |
41 | assert_tag :ul, :attributes => { :class => 'pages-hierarchy' }, |
|
41 | assert_tag :ul, :attributes => { :class => 'pages-hierarchy' }, | |
42 | :child => { :tag => 'li', |
|
42 | :child => { :tag => 'li', | |
43 | :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' }, |
|
43 | :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' }, | |
44 | :content => 'Page with an inline image' } } |
|
44 | :content => 'Page with an inline image' } } | |
45 | end |
|
45 | end | |
46 |
|
46 | |||
47 | def test_show_page_with_name |
|
47 | def test_show_page_with_name | |
48 | get :index, :id => 1, :page => 'Another_page' |
|
48 | get :index, :id => 1, :page => 'Another_page' | |
49 | assert_response :success |
|
49 | assert_response :success | |
50 | assert_template 'show' |
|
50 | assert_template 'show' | |
51 | assert_tag :tag => 'h1', :content => /Another page/ |
|
51 | assert_tag :tag => 'h1', :content => /Another page/ | |
52 | # Included page with an inline image |
|
52 | # Included page with an inline image | |
53 | assert_tag :tag => 'p', :content => /This is an inline image/ |
|
53 | assert_tag :tag => 'p', :content => /This is an inline image/ | |
54 | assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3', |
|
54 | assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3', | |
55 | :alt => 'This is a logo' } |
|
55 | :alt => 'This is a logo' } | |
56 | end |
|
56 | end | |
57 |
|
57 | |||
58 | def test_show_unexistent_page_without_edit_right |
|
58 | def test_show_unexistent_page_without_edit_right | |
59 | get :index, :id => 1, :page => 'Unexistent page' |
|
59 | get :index, :id => 1, :page => 'Unexistent page' | |
60 | assert_response 404 |
|
60 | assert_response 404 | |
61 | end |
|
61 | end | |
62 |
|
62 | |||
63 | def test_show_unexistent_page_with_edit_right |
|
63 | def test_show_unexistent_page_with_edit_right | |
64 | @request.session[:user_id] = 2 |
|
64 | @request.session[:user_id] = 2 | |
65 | get :index, :id => 1, :page => 'Unexistent page' |
|
65 | get :index, :id => 1, :page => 'Unexistent page' | |
66 | assert_response :success |
|
66 | assert_response :success | |
67 | assert_template 'edit' |
|
67 | assert_template 'edit' | |
68 | end |
|
68 | end | |
69 |
|
69 | |||
70 | def test_create_page |
|
70 | def test_create_page | |
71 | @request.session[:user_id] = 2 |
|
71 | @request.session[:user_id] = 2 | |
72 | post :edit, :id => 1, |
|
72 | post :edit, :id => 1, | |
73 | :page => 'New page', |
|
73 | :page => 'New page', | |
74 | :content => {:comments => 'Created the page', |
|
74 | :content => {:comments => 'Created the page', | |
75 | :text => "h1. New page\n\nThis is a new page", |
|
75 | :text => "h1. New page\n\nThis is a new page", | |
76 | :version => 0} |
|
76 | :version => 0} | |
77 | assert_redirected_to 'wiki/ecookbook/New_page' |
|
77 | assert_redirected_to 'wiki/ecookbook/New_page' | |
78 | page = Project.find(1).wiki.find_page('New page') |
|
78 | page = Project.find(1).wiki.find_page('New page') | |
79 | assert !page.new_record? |
|
79 | assert !page.new_record? | |
80 | assert_not_nil page.content |
|
80 | assert_not_nil page.content | |
81 | assert_equal 'Created the page', page.content.comments |
|
81 | assert_equal 'Created the page', page.content.comments | |
82 | end |
|
82 | end | |
83 |
|
83 | |||
84 | def test_preview |
|
84 | def test_preview | |
85 | @request.session[:user_id] = 2 |
|
85 | @request.session[:user_id] = 2 | |
86 | xhr :post, :preview, :id => 1, :page => 'CookBook_documentation', |
|
86 | xhr :post, :preview, :id => 1, :page => 'CookBook_documentation', | |
87 | :content => { :comments => '', |
|
87 | :content => { :comments => '', | |
88 | :text => 'this is a *previewed text*', |
|
88 | :text => 'this is a *previewed text*', | |
89 | :version => 3 } |
|
89 | :version => 3 } | |
90 | assert_response :success |
|
90 | assert_response :success | |
91 | assert_template 'common/_preview' |
|
91 | assert_template 'common/_preview' | |
92 | assert_tag :tag => 'strong', :content => /previewed text/ |
|
92 | assert_tag :tag => 'strong', :content => /previewed text/ | |
93 | end |
|
93 | end | |
94 |
|
94 | |||
95 | def test_preview_new_page |
|
95 | def test_preview_new_page | |
96 | @request.session[:user_id] = 2 |
|
96 | @request.session[:user_id] = 2 | |
97 | xhr :post, :preview, :id => 1, :page => 'New page', |
|
97 | xhr :post, :preview, :id => 1, :page => 'New page', | |
98 | :content => { :text => 'h1. New page', |
|
98 | :content => { :text => 'h1. New page', | |
99 | :comments => '', |
|
99 | :comments => '', | |
100 | :version => 0 } |
|
100 | :version => 0 } | |
101 | assert_response :success |
|
101 | assert_response :success | |
102 | assert_template 'common/_preview' |
|
102 | assert_template 'common/_preview' | |
103 | assert_tag :tag => 'h1', :content => /New page/ |
|
103 | assert_tag :tag => 'h1', :content => /New page/ | |
104 | end |
|
104 | end | |
105 |
|
105 | |||
106 | def test_history |
|
106 | def test_history | |
107 | get :history, :id => 1, :page => 'CookBook_documentation' |
|
107 | get :history, :id => 1, :page => 'CookBook_documentation' | |
108 | assert_response :success |
|
108 | assert_response :success | |
109 | assert_template 'history' |
|
109 | assert_template 'history' | |
110 | assert_not_nil assigns(:versions) |
|
110 | assert_not_nil assigns(:versions) | |
111 | assert_equal 3, assigns(:versions).size |
|
111 | assert_equal 3, assigns(:versions).size | |
|
112 | assert_select "input[type=submit][name=commit]" | |||
112 | end |
|
113 | end | |
113 |
|
114 | |||
|
115 | def test_history_with_one_version | |||
|
116 | get :history, :id => 1, :page => 'Another_page' | |||
|
117 | assert_response :success | |||
|
118 | assert_template 'history' | |||
|
119 | assert_not_nil assigns(:versions) | |||
|
120 | assert_equal 1, assigns(:versions).size | |||
|
121 | assert_select "input[type=submit][name=commit]", false | |||
|
122 | end | |||
|
123 | ||||
114 | def test_diff |
|
124 | def test_diff | |
115 | get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1 |
|
125 | get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1 | |
116 | assert_response :success |
|
126 | assert_response :success | |
117 | assert_template 'diff' |
|
127 | assert_template 'diff' | |
118 | assert_tag :tag => 'span', :attributes => { :class => 'diff_in'}, |
|
128 | assert_tag :tag => 'span', :attributes => { :class => 'diff_in'}, | |
119 | :content => /updated/ |
|
129 | :content => /updated/ | |
120 | end |
|
130 | end | |
121 |
|
131 | |||
122 | def test_annotate |
|
132 | def test_annotate | |
123 | get :annotate, :id => 1, :page => 'CookBook_documentation', :version => 2 |
|
133 | get :annotate, :id => 1, :page => 'CookBook_documentation', :version => 2 | |
124 | assert_response :success |
|
134 | assert_response :success | |
125 | assert_template 'annotate' |
|
135 | assert_template 'annotate' | |
126 | # Line 1 |
|
136 | # Line 1 | |
127 | assert_tag :tag => 'tr', :child => { :tag => 'th', :attributes => {:class => 'line-num'}, :content => '1' }, |
|
137 | assert_tag :tag => 'tr', :child => { :tag => 'th', :attributes => {:class => 'line-num'}, :content => '1' }, | |
128 | :child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /John Smith/ }, |
|
138 | :child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /John Smith/ }, | |
129 | :child => { :tag => 'td', :content => /h1\. CookBook documentation/ } |
|
139 | :child => { :tag => 'td', :content => /h1\. CookBook documentation/ } | |
130 | # Line 2 |
|
140 | # Line 2 | |
131 | assert_tag :tag => 'tr', :child => { :tag => 'th', :attributes => {:class => 'line-num'}, :content => '2' }, |
|
141 | assert_tag :tag => 'tr', :child => { :tag => 'th', :attributes => {:class => 'line-num'}, :content => '2' }, | |
132 | :child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/ }, |
|
142 | :child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/ }, | |
133 | :child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ } |
|
143 | :child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ } | |
134 | end |
|
144 | end | |
135 |
|
145 | |||
136 | def test_rename_with_redirect |
|
146 | def test_rename_with_redirect | |
137 | @request.session[:user_id] = 2 |
|
147 | @request.session[:user_id] = 2 | |
138 | post :rename, :id => 1, :page => 'Another_page', |
|
148 | post :rename, :id => 1, :page => 'Another_page', | |
139 | :wiki_page => { :title => 'Another renamed page', |
|
149 | :wiki_page => { :title => 'Another renamed page', | |
140 | :redirect_existing_links => 1 } |
|
150 | :redirect_existing_links => 1 } | |
141 | assert_redirected_to 'wiki/ecookbook/Another_renamed_page' |
|
151 | assert_redirected_to 'wiki/ecookbook/Another_renamed_page' | |
142 | wiki = Project.find(1).wiki |
|
152 | wiki = Project.find(1).wiki | |
143 | # Check redirects |
|
153 | # Check redirects | |
144 | assert_not_nil wiki.find_page('Another page') |
|
154 | assert_not_nil wiki.find_page('Another page') | |
145 | assert_nil wiki.find_page('Another page', :with_redirect => false) |
|
155 | assert_nil wiki.find_page('Another page', :with_redirect => false) | |
146 | end |
|
156 | end | |
147 |
|
157 | |||
148 | def test_rename_without_redirect |
|
158 | def test_rename_without_redirect | |
149 | @request.session[:user_id] = 2 |
|
159 | @request.session[:user_id] = 2 | |
150 | post :rename, :id => 1, :page => 'Another_page', |
|
160 | post :rename, :id => 1, :page => 'Another_page', | |
151 | :wiki_page => { :title => 'Another renamed page', |
|
161 | :wiki_page => { :title => 'Another renamed page', | |
152 | :redirect_existing_links => "0" } |
|
162 | :redirect_existing_links => "0" } | |
153 | assert_redirected_to 'wiki/ecookbook/Another_renamed_page' |
|
163 | assert_redirected_to 'wiki/ecookbook/Another_renamed_page' | |
154 | wiki = Project.find(1).wiki |
|
164 | wiki = Project.find(1).wiki | |
155 | # Check that there's no redirects |
|
165 | # Check that there's no redirects | |
156 | assert_nil wiki.find_page('Another page') |
|
166 | assert_nil wiki.find_page('Another page') | |
157 | end |
|
167 | end | |
158 |
|
168 | |||
159 | def test_destroy |
|
169 | def test_destroy | |
160 | @request.session[:user_id] = 2 |
|
170 | @request.session[:user_id] = 2 | |
161 | post :destroy, :id => 1, :page => 'CookBook_documentation' |
|
171 | post :destroy, :id => 1, :page => 'CookBook_documentation' | |
162 | assert_redirected_to 'wiki/ecookbook/Page_index/special' |
|
172 | assert_redirected_to 'wiki/ecookbook/Page_index/special' | |
163 | end |
|
173 | end | |
164 |
|
174 | |||
165 | def test_page_index |
|
175 | def test_page_index | |
166 | get :special, :id => 'ecookbook', :page => 'Page_index' |
|
176 | get :special, :id => 'ecookbook', :page => 'Page_index' | |
167 | assert_response :success |
|
177 | assert_response :success | |
168 | assert_template 'special_page_index' |
|
178 | assert_template 'special_page_index' | |
169 | pages = assigns(:pages) |
|
179 | pages = assigns(:pages) | |
170 | assert_not_nil pages |
|
180 | assert_not_nil pages | |
171 | assert_equal Project.find(1).wiki.pages.size, pages.size |
|
181 | assert_equal Project.find(1).wiki.pages.size, pages.size | |
172 |
|
182 | |||
173 | assert_tag :ul, :attributes => { :class => 'pages-hierarchy' }, |
|
183 | assert_tag :ul, :attributes => { :class => 'pages-hierarchy' }, | |
174 | :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/CookBook_documentation' }, |
|
184 | :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/CookBook_documentation' }, | |
175 | :content => 'CookBook documentation' }, |
|
185 | :content => 'CookBook documentation' }, | |
176 | :child => { :tag => 'ul', |
|
186 | :child => { :tag => 'ul', | |
177 | :child => { :tag => 'li', |
|
187 | :child => { :tag => 'li', | |
178 | :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' }, |
|
188 | :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' }, | |
179 | :content => 'Page with an inline image' } } } }, |
|
189 | :content => 'Page with an inline image' } } } }, | |
180 | :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Another_page' }, |
|
190 | :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Another_page' }, | |
181 | :content => 'Another page' } } |
|
191 | :content => 'Another page' } } | |
182 | end |
|
192 | end | |
183 |
|
193 | |||
184 | def test_not_found |
|
194 | def test_not_found | |
185 | get :index, :id => 999 |
|
195 | get :index, :id => 999 | |
186 | assert_response 404 |
|
196 | assert_response 404 | |
187 | end |
|
197 | end | |
188 |
|
198 | |||
189 | def test_protect_page |
|
199 | def test_protect_page | |
190 | page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page') |
|
200 | page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page') | |
191 | assert !page.protected? |
|
201 | assert !page.protected? | |
192 | @request.session[:user_id] = 2 |
|
202 | @request.session[:user_id] = 2 | |
193 | post :protect, :id => 1, :page => page.title, :protected => '1' |
|
203 | post :protect, :id => 1, :page => page.title, :protected => '1' | |
194 | assert_redirected_to 'wiki/ecookbook/Another_page' |
|
204 | assert_redirected_to 'wiki/ecookbook/Another_page' | |
195 | assert page.reload.protected? |
|
205 | assert page.reload.protected? | |
196 | end |
|
206 | end | |
197 |
|
207 | |||
198 | def test_unprotect_page |
|
208 | def test_unprotect_page | |
199 | page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation') |
|
209 | page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation') | |
200 | assert page.protected? |
|
210 | assert page.protected? | |
201 | @request.session[:user_id] = 2 |
|
211 | @request.session[:user_id] = 2 | |
202 | post :protect, :id => 1, :page => page.title, :protected => '0' |
|
212 | post :protect, :id => 1, :page => page.title, :protected => '0' | |
203 | assert_redirected_to 'wiki/ecookbook' |
|
213 | assert_redirected_to 'wiki/ecookbook' | |
204 | assert !page.reload.protected? |
|
214 | assert !page.reload.protected? | |
205 | end |
|
215 | end | |
206 |
|
216 | |||
207 | def test_show_page_with_edit_link |
|
217 | def test_show_page_with_edit_link | |
208 | @request.session[:user_id] = 2 |
|
218 | @request.session[:user_id] = 2 | |
209 | get :index, :id => 1 |
|
219 | get :index, :id => 1 | |
210 | assert_response :success |
|
220 | assert_response :success | |
211 | assert_template 'show' |
|
221 | assert_template 'show' | |
212 | assert_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' } |
|
222 | assert_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' } | |
213 | end |
|
223 | end | |
214 |
|
224 | |||
215 | def test_show_page_without_edit_link |
|
225 | def test_show_page_without_edit_link | |
216 | @request.session[:user_id] = 4 |
|
226 | @request.session[:user_id] = 4 | |
217 | get :index, :id => 1 |
|
227 | get :index, :id => 1 | |
218 | assert_response :success |
|
228 | assert_response :success | |
219 | assert_template 'show' |
|
229 | assert_template 'show' | |
220 | assert_no_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' } |
|
230 | assert_no_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' } | |
221 | end |
|
231 | end | |
222 |
|
232 | |||
223 | def test_edit_unprotected_page |
|
233 | def test_edit_unprotected_page | |
224 | # Non members can edit unprotected wiki pages |
|
234 | # Non members can edit unprotected wiki pages | |
225 | @request.session[:user_id] = 4 |
|
235 | @request.session[:user_id] = 4 | |
226 | get :edit, :id => 1, :page => 'Another_page' |
|
236 | get :edit, :id => 1, :page => 'Another_page' | |
227 | assert_response :success |
|
237 | assert_response :success | |
228 | assert_template 'edit' |
|
238 | assert_template 'edit' | |
229 | end |
|
239 | end | |
230 |
|
240 | |||
231 | def test_edit_protected_page_by_nonmember |
|
241 | def test_edit_protected_page_by_nonmember | |
232 | # Non members can't edit protected wiki pages |
|
242 | # Non members can't edit protected wiki pages | |
233 | @request.session[:user_id] = 4 |
|
243 | @request.session[:user_id] = 4 | |
234 | get :edit, :id => 1, :page => 'CookBook_documentation' |
|
244 | get :edit, :id => 1, :page => 'CookBook_documentation' | |
235 | assert_response 403 |
|
245 | assert_response 403 | |
236 | end |
|
246 | end | |
237 |
|
247 | |||
238 | def test_edit_protected_page_by_member |
|
248 | def test_edit_protected_page_by_member | |
239 | @request.session[:user_id] = 2 |
|
249 | @request.session[:user_id] = 2 | |
240 | get :edit, :id => 1, :page => 'CookBook_documentation' |
|
250 | get :edit, :id => 1, :page => 'CookBook_documentation' | |
241 | assert_response :success |
|
251 | assert_response :success | |
242 | assert_template 'edit' |
|
252 | assert_template 'edit' | |
243 | end |
|
253 | end | |
244 | end |
|
254 | end |
General Comments 0
You need to be logged in to leave comments.
Login now