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