Revision 4265
Added by Eric Davis over 14 years ago
trunk/app/controllers/wiki_controller.rb | ||
---|---|---|
79 | 79 |
attachments = Attachment.attach_files(@page, params[:attachments]) |
80 | 80 |
render_attachment_warning_if_needed(@page) |
81 | 81 |
# don't save if text wasn't changed |
82 |
redirect_to :action => 'index', :id => @project, :page => @page.title |
|
82 |
redirect_to :action => 'index', :project_id => @project, :page => @page.title
|
|
83 | 83 |
return |
84 | 84 |
end |
85 | 85 |
#@content.text = params[:content][:text] |
... | ... | |
91 | 91 |
attachments = Attachment.attach_files(@page, params[:attachments]) |
92 | 92 |
render_attachment_warning_if_needed(@page) |
93 | 93 |
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page}) |
94 |
redirect_to :action => 'index', :id => @project, :page => @page.title |
|
94 |
redirect_to :action => 'index', :project_id => @project, :page => @page.title
|
|
95 | 95 |
end |
96 | 96 |
end |
97 | 97 |
rescue ActiveRecord::StaleObjectError |
... | ... | |
107 | 107 |
@original_title = @page.pretty_title |
108 | 108 |
if request.post? && @page.update_attributes(params[:wiki_page]) |
109 | 109 |
flash[:notice] = l(:notice_successful_update) |
110 |
redirect_to :action => 'index', :id => @project, :page => @page.title |
|
110 |
redirect_to :action => 'index', :project_id => @project, :page => @page.title
|
|
111 | 111 |
end |
112 | 112 |
end |
113 | 113 |
|
114 | 114 |
def protect |
115 | 115 |
@page.update_attribute :protected, params[:protected] |
116 |
redirect_to :action => 'index', :id => @project, :page => @page.title |
|
116 |
redirect_to :action => 'index', :project_id => @project, :page => @page.title
|
|
117 | 117 |
end |
118 | 118 |
|
119 | 119 |
# show page history |
... | ... | |
166 | 166 |
end |
167 | 167 |
end |
168 | 168 |
@page.destroy |
169 |
redirect_to :action => 'page_index', :id => @project |
|
169 |
redirect_to :action => 'page_index', :project_id => @project
|
|
170 | 170 |
end |
171 | 171 |
|
172 | 172 |
# Export wiki to a single html file |
... | ... | |
176 | 176 |
export = render_to_string :action => 'export_multiple', :layout => false |
177 | 177 |
send_data(export, :type => 'text/html', :filename => "wiki.html") |
178 | 178 |
else |
179 |
redirect_to :action => 'index', :id => @project, :page => nil |
|
179 |
redirect_to :action => 'index', :project_id => @project, :page => nil
|
|
180 | 180 |
end |
181 | 181 |
end |
182 | 182 |
|
... | ... | |
210 | 210 |
private |
211 | 211 |
|
212 | 212 |
def find_wiki |
213 |
@project = Project.find(params[:id]) |
|
213 |
@project = Project.find(params[:project_id])
|
|
214 | 214 |
@wiki = @project.wiki |
215 | 215 |
render_404 unless @wiki |
216 | 216 |
rescue ActiveRecord::RecordNotFound |
trunk/app/helpers/application_helper.rb | ||
---|---|---|
182 | 182 |
content << "<ul class=\"pages-hierarchy\">\n" |
183 | 183 |
pages[node].each do |page| |
184 | 184 |
content << "<li>" |
185 |
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'index', :id => page.project, :page => page.title}, |
|
185 |
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'index', :project_id => page.project, :page => page.title},
|
|
186 | 186 |
:title => (page.respond_to?(:updated_on) ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil)) |
187 | 187 |
content << "\n" + render_page_hierarchy(pages, page.id) if pages[page.id] |
188 | 188 |
content << "</li>\n" |
... | ... | |
551 | 551 |
when :local; "#{title}.html" |
552 | 552 |
when :anchor; "##{title}" # used for single-file wiki export |
553 | 553 |
else |
554 |
url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :id => link_project, :page => Wiki.titleize(page), :anchor => anchor) |
|
554 |
url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :project_id => link_project, :page => Wiki.titleize(page), :anchor => anchor)
|
|
555 | 555 |
end |
556 | 556 |
link_to((title || page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new'))) |
557 | 557 |
else |
trunk/app/views/wiki/annotate.rhtml | ||
---|---|---|
18 | 18 |
<% @annotate.lines.each do |line| -%> |
19 | 19 |
<tr class="bloc-<%= colors[line[0]] %>"> |
20 | 20 |
<th class="line-num"><%= line_num %></th> |
21 |
<td class="revision"><%= link_to line[0], :controller => 'wiki', :action => 'index', :id => @project, :page => @page.title, :version => line[0] %></td> |
|
21 |
<td class="revision"><%= link_to line[0], :controller => 'wiki', :action => 'index', :project_id => @project, :page => @page.title, :version => line[0] %></td>
|
|
22 | 22 |
<td class="author"><%= h(line[1]) %></td> |
23 | 23 |
<td class="line-code"><pre><%=h line[2] %></pre></td> |
24 | 24 |
</tr> |
trunk/app/views/wiki/destroy.rhtml | ||
---|---|---|
15 | 15 |
</div> |
16 | 16 |
|
17 | 17 |
<%= submit_tag l(:button_apply) %> |
18 |
<%= link_to l(:button_cancel), :controller => 'wiki', :action => 'index', :id => @project, :page => @page.title %> |
|
18 |
<%= link_to l(:button_cancel), :controller => 'wiki', :action => 'index', :project_id => @project, :page => @page.title %>
|
|
19 | 19 |
<% end %> |
trunk/app/views/wiki/edit.rhtml | ||
---|---|---|
10 | 10 |
|
11 | 11 |
<p><%= submit_tag l(:button_save) %> |
12 | 12 |
<%= link_to_remote l(:label_preview), |
13 |
{ :url => { :controller => 'wiki', :action => 'preview', :id => @project, :page => @page.title }, |
|
13 |
{ :url => { :controller => 'wiki', :action => 'preview', :project_id => @project, :page => @page.title },
|
|
14 | 14 |
:method => 'post', |
15 | 15 |
:update => 'preview', |
16 | 16 |
:with => "Form.serialize('wiki_form')", |
trunk/app/views/wiki/history.rhtml | ||
---|---|---|
3 | 3 |
<h3><%= l(:label_history) %></h3> |
4 | 4 |
|
5 | 5 |
<% form_tag({:action => "diff"}, :method => :get) do %> |
6 |
<%= hidden_field_tag('project_id', h(@project.to_param)) %> |
|
6 | 7 |
<table class="list"> |
7 | 8 |
<thead><tr> |
8 | 9 |
<th>#</th> |
trunk/config/routes.rb | ||
---|---|---|
29 | 29 |
map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post} |
30 | 30 |
map.with_options :controller => 'wiki' do |wiki_routes| |
31 | 31 |
wiki_routes.with_options :conditions => {:method => :get} do |wiki_views| |
32 |
wiki_views.connect 'projects/:id/wiki/export', :action => 'export' |
|
33 |
wiki_views.connect 'projects/:id/wiki/page_index', :action => 'page_index' |
|
34 |
wiki_views.connect 'projects/:id/wiki/date_index', :action => 'date_index' |
|
35 |
wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil |
|
36 |
wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit' |
|
37 |
wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename' |
|
38 |
wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history' |
|
39 |
wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff' |
|
40 |
wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate' |
|
32 |
wiki_views.connect 'projects/:project_id/wiki/export', :action => 'export'
|
|
33 |
wiki_views.connect 'projects/:project_id/wiki/page_index', :action => 'page_index'
|
|
34 |
wiki_views.connect 'projects/:project_id/wiki/date_index', :action => 'date_index'
|
|
35 |
wiki_views.connect 'projects/:project_id/wiki/:page', :action => 'index', :page => nil
|
|
36 |
wiki_views.connect 'projects/:project_id/wiki/:page/edit', :action => 'edit'
|
|
37 |
wiki_views.connect 'projects/:project_id/wiki/:page/rename', :action => 'rename'
|
|
38 |
wiki_views.connect 'projects/:project_id/wiki/:page/history', :action => 'history'
|
|
39 |
wiki_views.connect 'projects/:project_id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff'
|
|
40 |
wiki_views.connect 'projects/:project_id/wiki/:page/annotate/:version', :action => 'annotate'
|
|
41 | 41 |
end |
42 | 42 |
|
43 |
wiki_routes.connect 'projects/:id/wiki/:page/:action', |
|
43 |
wiki_routes.connect 'projects/:project_id/wiki/:page/:action',
|
|
44 | 44 |
:action => /edit|rename|destroy|preview|protect/, |
45 | 45 |
:conditions => {:method => :post} |
46 | 46 |
end |
trunk/lib/redmine.rb | ||
---|---|---|
195 | 195 |
menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar |
196 | 196 |
menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural |
197 | 197 |
menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural |
198 |
menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil }, |
|
198 |
menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil }, :param => :project_id,
|
|
199 | 199 |
:if => Proc.new { |p| p.wiki && !p.wiki.new_record? } |
200 | 200 |
menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, |
201 | 201 |
:if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural |
trunk/test/functional/wiki_controller_test.rb | ||
---|---|---|
32 | 32 |
end |
33 | 33 |
|
34 | 34 |
def test_show_start_page |
35 |
get :index, :id => 'ecookbook' |
|
35 |
get :index, :project_id => 'ecookbook'
|
|
36 | 36 |
assert_response :success |
37 | 37 |
assert_template 'show' |
38 | 38 |
assert_tag :tag => 'h1', :content => /CookBook documentation/ |
... | ... | |
45 | 45 |
end |
46 | 46 |
|
47 | 47 |
def test_show_page_with_name |
48 |
get :index, :id => 1, :page => 'Another_page' |
|
48 |
get :index, :project_id => 1, :page => 'Another_page'
|
|
49 | 49 |
assert_response :success |
50 | 50 |
assert_template 'show' |
51 | 51 |
assert_tag :tag => 'h1', :content => /Another page/ |
... | ... | |
60 | 60 |
page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar') |
61 | 61 |
page.save! |
62 | 62 |
|
63 |
get :index, :id => 1, :page => 'Another_page' |
|
63 |
get :index, :project_id => 1, :page => 'Another_page'
|
|
64 | 64 |
assert_response :success |
65 | 65 |
assert_tag :tag => 'div', :attributes => {:id => 'sidebar'}, |
66 | 66 |
:content => /Side bar content for test_show_with_sidebar/ |
67 | 67 |
end |
68 | 68 |
|
69 | 69 |
def test_show_unexistent_page_without_edit_right |
70 |
get :index, :id => 1, :page => 'Unexistent page' |
|
70 |
get :index, :project_id => 1, :page => 'Unexistent page'
|
|
71 | 71 |
assert_response 404 |
72 | 72 |
end |
73 | 73 |
|
74 | 74 |
def test_show_unexistent_page_with_edit_right |
75 | 75 |
@request.session[:user_id] = 2 |
76 |
get :index, :id => 1, :page => 'Unexistent page' |
|
76 |
get :index, :project_id => 1, :page => 'Unexistent page'
|
|
77 | 77 |
assert_response :success |
78 | 78 |
assert_template 'edit' |
79 | 79 |
end |
80 | 80 |
|
81 | 81 |
def test_create_page |
82 | 82 |
@request.session[:user_id] = 2 |
83 |
post :edit, :id => 1, |
|
83 |
post :edit, :project_id => 1,
|
|
84 | 84 |
:page => 'New page', |
85 | 85 |
:content => {:comments => 'Created the page', |
86 | 86 |
:text => "h1. New page\n\nThis is a new page", |
87 | 87 |
:version => 0} |
88 |
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'New_page' |
|
88 |
assert_redirected_to :action => 'index', :project_id => 'ecookbook', :page => 'New_page'
|
|
89 | 89 |
page = Project.find(1).wiki.find_page('New page') |
90 | 90 |
assert !page.new_record? |
91 | 91 |
assert_not_nil page.content |
... | ... | |
96 | 96 |
@request.session[:user_id] = 2 |
97 | 97 |
assert_difference 'WikiPage.count' do |
98 | 98 |
assert_difference 'Attachment.count' do |
99 |
post :edit, :id => 1, |
|
99 |
post :edit, :project_id => 1,
|
|
100 | 100 |
:page => 'New page', |
101 | 101 |
:content => {:comments => 'Created the page', |
102 | 102 |
:text => "h1. New page\n\nThis is a new page", |
... | ... | |
111 | 111 |
|
112 | 112 |
def test_preview |
113 | 113 |
@request.session[:user_id] = 2 |
114 |
xhr :post, :preview, :id => 1, :page => 'CookBook_documentation', |
|
114 |
xhr :post, :preview, :project_id => 1, :page => 'CookBook_documentation',
|
|
115 | 115 |
:content => { :comments => '', |
116 | 116 |
:text => 'this is a *previewed text*', |
117 | 117 |
:version => 3 } |
... | ... | |
122 | 122 |
|
123 | 123 |
def test_preview_new_page |
124 | 124 |
@request.session[:user_id] = 2 |
125 |
xhr :post, :preview, :id => 1, :page => 'New page', |
|
125 |
xhr :post, :preview, :project_id => 1, :page => 'New page',
|
|
126 | 126 |
:content => { :text => 'h1. New page', |
127 | 127 |
:comments => '', |
128 | 128 |
:version => 0 } |
... | ... | |
132 | 132 |
end |
133 | 133 |
|
134 | 134 |
def test_history |
135 |
get :history, :id => 1, :page => 'CookBook_documentation' |
|
135 |
get :history, :project_id => 1, :page => 'CookBook_documentation'
|
|
136 | 136 |
assert_response :success |
137 | 137 |
assert_template 'history' |
138 | 138 |
assert_not_nil assigns(:versions) |
... | ... | |
141 | 141 |
end |
142 | 142 |
|
143 | 143 |
def test_history_with_one_version |
144 |
get :history, :id => 1, :page => 'Another_page' |
|
144 |
get :history, :project_id => 1, :page => 'Another_page'
|
|
145 | 145 |
assert_response :success |
146 | 146 |
assert_template 'history' |
147 | 147 |
assert_not_nil assigns(:versions) |
... | ... | |
150 | 150 |
end |
151 | 151 |
|
152 | 152 |
def test_diff |
153 |
get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1 |
|
153 |
get :diff, :project_id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1
|
|
154 | 154 |
assert_response :success |
155 | 155 |
assert_template 'diff' |
156 | 156 |
assert_tag :tag => 'span', :attributes => { :class => 'diff_in'}, |
... | ... | |
158 | 158 |
end |
159 | 159 |
|
160 | 160 |
def test_annotate |
161 |
get :annotate, :id => 1, :page => 'CookBook_documentation', :version => 2 |
|
161 |
get :annotate, :project_id => 1, :page => 'CookBook_documentation', :version => 2
|
|
162 | 162 |
assert_response :success |
163 | 163 |
assert_template 'annotate' |
164 | 164 |
# Line 1 |
... | ... | |
173 | 173 |
|
174 | 174 |
def test_rename_with_redirect |
175 | 175 |
@request.session[:user_id] = 2 |
176 |
post :rename, :id => 1, :page => 'Another_page', |
|
176 |
post :rename, :project_id => 1, :page => 'Another_page',
|
|
177 | 177 |
:wiki_page => { :title => 'Another renamed page', |
178 | 178 |
:redirect_existing_links => 1 } |
179 |
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_renamed_page' |
|
179 |
assert_redirected_to :action => 'index', :project_id => 'ecookbook', :page => 'Another_renamed_page'
|
|
180 | 180 |
wiki = Project.find(1).wiki |
181 | 181 |
# Check redirects |
182 | 182 |
assert_not_nil wiki.find_page('Another page') |
... | ... | |
185 | 185 |
|
186 | 186 |
def test_rename_without_redirect |
187 | 187 |
@request.session[:user_id] = 2 |
188 |
post :rename, :id => 1, :page => 'Another_page', |
|
188 |
post :rename, :project_id => 1, :page => 'Another_page',
|
|
189 | 189 |
:wiki_page => { :title => 'Another renamed page', |
190 | 190 |
:redirect_existing_links => "0" } |
191 |
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_renamed_page' |
|
191 |
assert_redirected_to :action => 'index', :project_id => 'ecookbook', :page => 'Another_renamed_page'
|
|
192 | 192 |
wiki = Project.find(1).wiki |
193 | 193 |
# Check that there's no redirects |
194 | 194 |
assert_nil wiki.find_page('Another page') |
... | ... | |
196 | 196 |
|
197 | 197 |
def test_destroy_child |
198 | 198 |
@request.session[:user_id] = 2 |
199 |
post :destroy, :id => 1, :page => 'Child_1' |
|
200 |
assert_redirected_to :action => 'page_index', :id => 'ecookbook' |
|
199 |
post :destroy, :project_id => 1, :page => 'Child_1'
|
|
200 |
assert_redirected_to :action => 'page_index', :project_id => 'ecookbook'
|
|
201 | 201 |
end |
202 | 202 |
|
203 | 203 |
def test_destroy_parent |
204 | 204 |
@request.session[:user_id] = 2 |
205 | 205 |
assert_no_difference('WikiPage.count') do |
206 |
post :destroy, :id => 1, :page => 'Another_page' |
|
206 |
post :destroy, :project_id => 1, :page => 'Another_page'
|
|
207 | 207 |
end |
208 | 208 |
assert_response :success |
209 | 209 |
assert_template 'destroy' |
... | ... | |
212 | 212 |
def test_destroy_parent_with_nullify |
213 | 213 |
@request.session[:user_id] = 2 |
214 | 214 |
assert_difference('WikiPage.count', -1) do |
215 |
post :destroy, :id => 1, :page => 'Another_page', :todo => 'nullify' |
|
215 |
post :destroy, :project_id => 1, :page => 'Another_page', :todo => 'nullify'
|
|
216 | 216 |
end |
217 |
assert_redirected_to :action => 'page_index', :id => 'ecookbook' |
|
217 |
assert_redirected_to :action => 'page_index', :project_id => 'ecookbook'
|
|
218 | 218 |
assert_nil WikiPage.find_by_id(2) |
219 | 219 |
end |
220 | 220 |
|
221 | 221 |
def test_destroy_parent_with_cascade |
222 | 222 |
@request.session[:user_id] = 2 |
223 | 223 |
assert_difference('WikiPage.count', -3) do |
224 |
post :destroy, :id => 1, :page => 'Another_page', :todo => 'destroy' |
|
224 |
post :destroy, :project_id => 1, :page => 'Another_page', :todo => 'destroy'
|
|
225 | 225 |
end |
226 |
assert_redirected_to :action => 'page_index', :id => 'ecookbook' |
|
226 |
assert_redirected_to :action => 'page_index', :project_id => 'ecookbook'
|
|
227 | 227 |
assert_nil WikiPage.find_by_id(2) |
228 | 228 |
assert_nil WikiPage.find_by_id(5) |
229 | 229 |
end |
... | ... | |
231 | 231 |
def test_destroy_parent_with_reassign |
232 | 232 |
@request.session[:user_id] = 2 |
233 | 233 |
assert_difference('WikiPage.count', -1) do |
234 |
post :destroy, :id => 1, :page => 'Another_page', :todo => 'reassign', :reassign_to_id => 1 |
|
234 |
post :destroy, :project_id => 1, :page => 'Another_page', :todo => 'reassign', :reassign_to_id => 1
|
|
235 | 235 |
end |
236 |
assert_redirected_to :action => 'page_index', :id => 'ecookbook' |
|
236 |
assert_redirected_to :action => 'page_index', :project_id => 'ecookbook'
|
|
237 | 237 |
assert_nil WikiPage.find_by_id(2) |
238 | 238 |
assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent |
239 | 239 |
end |
240 | 240 |
|
241 | 241 |
def test_page_index |
242 |
get :page_index, :id => 'ecookbook' |
|
242 |
get :page_index, :project_id => 'ecookbook'
|
|
243 | 243 |
assert_response :success |
244 | 244 |
assert_template 'page_index' |
245 | 245 |
pages = assigns(:pages) |
... | ... | |
261 | 261 |
context "with an authorized user to export the wiki" do |
262 | 262 |
setup do |
263 | 263 |
@request.session[:user_id] = 2 |
264 |
get :export, :id => 'ecookbook' |
|
264 |
get :export, :project_id => 'ecookbook'
|
|
265 | 265 |
end |
266 | 266 |
|
267 | 267 |
should_respond_with :success |
... | ... | |
277 | 277 |
|
278 | 278 |
context "with an unauthorized user" do |
279 | 279 |
setup do |
280 |
get :export, :id => 'ecookbook' |
|
280 |
get :export, :project_id => 'ecookbook'
|
|
281 | 281 |
|
282 | 282 |
should_respond_with :redirect |
283 |
should_redirect_to('wiki index') { {:action => 'index', :id => @project, :page => nil} } |
|
283 |
should_redirect_to('wiki index') { {:action => 'index', :project_id => @project, :page => nil} }
|
|
284 | 284 |
end |
285 | 285 |
end |
286 | 286 |
end |
287 | 287 |
|
288 | 288 |
context "GET :date_index" do |
289 | 289 |
setup do |
290 |
get :date_index, :id => 'ecookbook' |
|
290 |
get :date_index, :project_id => 'ecookbook'
|
|
291 | 291 |
end |
292 | 292 |
|
293 | 293 |
should_respond_with :success |
... | ... | |
298 | 298 |
end |
299 | 299 |
|
300 | 300 |
def test_not_found |
301 |
get :index, :id => 999 |
|
301 |
get :index, :project_id => 999
|
|
302 | 302 |
assert_response 404 |
303 | 303 |
end |
304 | 304 |
|
... | ... | |
306 | 306 |
page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page') |
307 | 307 |
assert !page.protected? |
308 | 308 |
@request.session[:user_id] = 2 |
309 |
post :protect, :id => 1, :page => page.title, :protected => '1' |
|
310 |
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_page' |
|
309 |
post :protect, :project_id => 1, :page => page.title, :protected => '1'
|
|
310 |
assert_redirected_to :action => 'index', :project_id => 'ecookbook', :page => 'Another_page'
|
|
311 | 311 |
assert page.reload.protected? |
312 | 312 |
end |
313 | 313 |
|
... | ... | |
315 | 315 |
page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation') |
316 | 316 |
assert page.protected? |
317 | 317 |
@request.session[:user_id] = 2 |
318 |
post :protect, :id => 1, :page => page.title, :protected => '0' |
|
319 |
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'CookBook_documentation' |
|
318 |
post :protect, :project_id => 1, :page => page.title, :protected => '0'
|
|
319 |
assert_redirected_to :action => 'index', :project_id => 'ecookbook', :page => 'CookBook_documentation'
|
|
320 | 320 |
assert !page.reload.protected? |
321 | 321 |
end |
322 | 322 |
|
323 | 323 |
def test_show_page_with_edit_link |
324 | 324 |
@request.session[:user_id] = 2 |
325 |
get :index, :id => 1 |
|
325 |
get :index, :project_id => 1
|
|
326 | 326 |
assert_response :success |
327 | 327 |
assert_template 'show' |
328 | 328 |
assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } |
... | ... | |
330 | 330 |
|
331 | 331 |
def test_show_page_without_edit_link |
332 | 332 |
@request.session[:user_id] = 4 |
333 |
get :index, :id => 1 |
|
333 |
get :index, :project_id => 1
|
|
334 | 334 |
assert_response :success |
335 | 335 |
assert_template 'show' |
336 | 336 |
assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } |
... | ... | |
339 | 339 |
def test_edit_unprotected_page |
340 | 340 |
# Non members can edit unprotected wiki pages |
341 | 341 |
@request.session[:user_id] = 4 |
342 |
get :edit, :id => 1, :page => 'Another_page' |
|
342 |
get :edit, :project_id => 1, :page => 'Another_page'
|
|
343 | 343 |
assert_response :success |
344 | 344 |
assert_template 'edit' |
345 | 345 |
end |
... | ... | |
347 | 347 |
def test_edit_protected_page_by_nonmember |
348 | 348 |
# Non members can't edit protected wiki pages |
349 | 349 |
@request.session[:user_id] = 4 |
350 |
get :edit, :id => 1, :page => 'CookBook_documentation' |
|
350 |
get :edit, :project_id => 1, :page => 'CookBook_documentation'
|
|
351 | 351 |
assert_response 403 |
352 | 352 |
end |
353 | 353 |
|
354 | 354 |
def test_edit_protected_page_by_member |
355 | 355 |
@request.session[:user_id] = 2 |
356 |
get :edit, :id => 1, :page => 'CookBook_documentation' |
|
356 |
get :edit, :project_id => 1, :page => 'CookBook_documentation'
|
|
357 | 357 |
assert_response :success |
358 | 358 |
assert_template 'edit' |
359 | 359 |
end |
360 | 360 |
|
361 | 361 |
def test_history_of_non_existing_page_should_return_404 |
362 |
get :history, :id => 1, :page => 'Unknown_page' |
|
362 |
get :history, :project_id => 1, :page => 'Unknown_page'
|
|
363 | 363 |
assert_response 404 |
364 | 364 |
end |
365 | 365 |
end |
trunk/test/integration/routing_test.rb | ||
---|---|---|
311 | 311 |
end |
312 | 312 |
|
313 | 313 |
context "wiki (singular, project's pages)" do |
314 |
should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'index', :id => '567' |
|
315 |
should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala' |
|
316 |
should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page' |
|
317 |
should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :id => '1', :page => 'CookBook_documentation' |
|
318 |
should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1", :controller => 'wiki', :action => 'diff', :id => '1', :page => 'CookBook_documentation', :version => '2', :version_from => '1' |
|
319 |
should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2' |
|
320 |
should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida' |
|
321 |
should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'page_index', :id => '567' |
|
322 |
should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'date_index', :id => '567' |
|
323 |
should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'export', :id => '567' |
|
314 |
should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'index', :project_id => '567'
|
|
315 |
should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'index', :project_id => '567', :page => 'lalala'
|
|
316 |
should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :project_id => '567', :page => 'my_page'
|
|
317 |
should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :project_id => '1', :page => 'CookBook_documentation'
|
|
318 |
should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1", :controller => 'wiki', :action => 'diff', :project_id => '1', :page => 'CookBook_documentation', :version => '2', :version_from => '1'
|
|
319 |
should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :project_id => '1', :page => 'CookBook_documentation', :version => '2'
|
|
320 |
should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :page => 'ladida'
|
|
321 |
should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'page_index', :project_id => '567'
|
|
322 |
should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'date_index', :project_id => '567'
|
|
323 |
should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'export', :project_id => '567'
|
|
324 | 324 |
|
325 |
should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page' |
|
326 |
should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :id => '567', :page => 'CookBook_documentation' |
|
327 |
should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida' |
|
328 |
should_route :post, "/projects/22/wiki/ladida/destroy", :controller => 'wiki', :action => 'destroy', :id => '22', :page => 'ladida' |
|
329 |
should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida' |
|
325 |
should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :project_id => '567', :page => 'my_page'
|
|
326 |
should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :project_id => '567', :page => 'CookBook_documentation'
|
|
327 |
should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :page => 'ladida'
|
|
328 |
should_route :post, "/projects/22/wiki/ladida/destroy", :controller => 'wiki', :action => 'destroy', :project_id => '22', :page => 'ladida'
|
|
329 |
should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :project_id => '22', :page => 'ladida'
|
|
330 | 330 |
end |
331 | 331 |
|
332 | 332 |
context "wikis (plural, admin setup)" do |
Also available in: Unified diff
Refactor: change :id on WikiController to use :project_id
Using :id to track projects on non-project controllers is confusing and
makes routing with resources difficult.