##// END OF EJS Templates
Refactor: extract #page_index from WikiController#special...
Eric Davis -
r4139:027110579438
parent child
Show More
@@ -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 => 'special', :id => @project, :page => 'Page_index'
169 redirect_to :action => 'page_index', :id => @project
170 end
170 end
171
171
172 # display special pages
172 # display special pages
@@ -174,7 +174,7 class WikiController < ApplicationController
174 page_title = params[:page].downcase
174 page_title = params[:page].downcase
175 case page_title
175 case page_title
176 # show pages index, sorted by title
176 # show pages index, sorted by title
177 when 'page_index', 'date_index'
177 when 'date_index'
178 load_pages_grouped_by_date_without_content
178 load_pages_grouped_by_date_without_content
179 when 'export'
179 when 'export'
180 redirect_to :action => 'export', :id => @project # Compatibility stub while refactoring
180 redirect_to :action => 'export', :id => @project # Compatibility stub while refactoring
@@ -197,6 +197,10 class WikiController < ApplicationController
197 redirect_to :action => 'index', :id => @project, :page => nil
197 redirect_to :action => 'index', :id => @project, :page => nil
198 end
198 end
199 end
199 end
200
201 def page_index
202 load_pages_grouped_by_date_without_content
203 end
200
204
201 def preview
205 def preview
202 page = @wiki.find_page(params[:page])
206 page = @wiki.find_page(params[:page])
@@ -5,5 +5,5
5 <h3><%= l(:label_wiki) %></h3>
5 <h3><%= l(:label_wiki) %></h3>
6
6
7 <%= link_to l(:field_start_page), {:action => 'index', :page => nil} %><br />
7 <%= link_to l(:field_start_page), {:action => 'index', :page => nil} %><br />
8 <%= link_to l(:label_index_by_title), {:action => 'special', :page => 'Page_index'} %><br />
8 <%= link_to l(:label_index_by_title), {:action => 'page_index'} %><br />
9 <%= link_to l(:label_index_by_date), {:action => 'special', :page => 'Date_index'} %><br />
9 <%= link_to l(:label_index_by_date), {:action => 'special', :page => 'Date_index'} %><br />
1 NO CONTENT: file renamed from app/views/wiki/special_page_index.rhtml to app/views/wiki/page_index.html.erb
NO CONTENT: file renamed from app/views/wiki/special_page_index.rhtml to app/views/wiki/page_index.html.erb
@@ -30,7 +30,8 ActionController::Routing::Routes.draw do |map|
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/:id/wiki/export', :action => 'export'
33 wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index/i
33 wiki_views.connect 'projects/:id/wiki/page_index', :action => 'page_index'
34 wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /date_index/i
34 wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil
35 wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil
35 wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit'
36 wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit'
36 wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename'
37 wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename'
@@ -111,7 +111,7 Redmine::AccessControl.map do |map|
111 map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
111 map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
112 map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
112 map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
113 map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member
113 map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member
114 map.permission :view_wiki_pages, :wiki => [:index, :special]
114 map.permission :view_wiki_pages, :wiki => [:index, :special, :page_index]
115 map.permission :export_wiki_pages, :wiki => [:export]
115 map.permission :export_wiki_pages, :wiki => [:export]
116 map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate]
116 map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate]
117 map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment]
117 map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment]
@@ -197,7 +197,7 class WikiControllerTest < ActionController::TestCase
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, :id => 1, :page => 'Child_1'
200 assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
200 assert_redirected_to :action => 'page_index', :id => 'ecookbook'
201 end
201 end
202
202
203 def test_destroy_parent
203 def test_destroy_parent
@@ -214,7 +214,7 class WikiControllerTest < ActionController::TestCase
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, :id => 1, :page => 'Another_page', :todo => 'nullify'
216 end
216 end
217 assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
217 assert_redirected_to :action => 'page_index', :id => 'ecookbook'
218 assert_nil WikiPage.find_by_id(2)
218 assert_nil WikiPage.find_by_id(2)
219 end
219 end
220
220
@@ -223,7 +223,7 class WikiControllerTest < ActionController::TestCase
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, :id => 1, :page => 'Another_page', :todo => 'destroy'
225 end
225 end
226 assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
226 assert_redirected_to :action => 'page_index', :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
@@ -233,15 +233,15 class WikiControllerTest < ActionController::TestCase
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, :id => 1, :page => 'Another_page', :todo => 'reassign', :reassign_to_id => 1
235 end
235 end
236 assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
236 assert_redirected_to :action => 'page_index', :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 :special, :id => 'ecookbook', :page => 'Page_index'
242 get :page_index, :id => 'ecookbook'
243 assert_response :success
243 assert_response :success
244 assert_template 'special_page_index'
244 assert_template 'page_index'
245 pages = assigns(:pages)
245 pages = assigns(:pages)
246 assert_not_nil pages
246 assert_not_nil pages
247 assert_equal Project.find(1).wiki.pages.size, pages.size
247 assert_equal Project.find(1).wiki.pages.size, pages.size
@@ -318,8 +318,7 class RoutingTest < ActionController::IntegrationTest
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', :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', :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', :id => '22', :page => 'ladida'
321 should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index'
321 should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'page_index', :id => '567'
322 should_route :get, "/projects/567/wiki/Page_Index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index'
323 should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index'
322 should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index'
324 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', :id => '567'
325
324
General Comments 0
You need to be logged in to leave comments. Login now