]> source.dussan.org Git - redmine.git/commitdiff
Refactor: extract #page_index from WikiController#special
authorEric Davis <edavis@littlestreamsoftware.com>
Fri, 15 Oct 2010 15:36:10 +0000 (15:36 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Fri, 15 Oct 2010 15:36:10 +0000 (15:36 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4253 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/wiki_controller.rb
app/views/wiki/_sidebar.rhtml
app/views/wiki/page_index.html.erb [new file with mode: 0644]
app/views/wiki/special_page_index.rhtml [deleted file]
config/routes.rb
lib/redmine.rb
test/functional/wiki_controller_test.rb
test/integration/routing_test.rb

index 402483cbcedd604b0f4f8de3d392dbb97296d9b2..7d8cb422c635d1aedbfc8fbcca4bdac3af99976e 100644 (file)
@@ -166,7 +166,7 @@ class WikiController < ApplicationController
       end
     end
     @page.destroy
-    redirect_to :action => 'special', :id => @project, :page => 'Page_index'
+    redirect_to :action => 'page_index', :id => @project
   end
 
   # display special pages
@@ -174,7 +174,7 @@ class WikiController < ApplicationController
     page_title = params[:page].downcase
     case page_title
     # show pages index, sorted by title
-    when 'page_index', 'date_index'
+    when 'date_index'
       load_pages_grouped_by_date_without_content
     when 'export'
       redirect_to :action => 'export', :id => @project # Compatibility stub while refactoring
@@ -197,6 +197,10 @@ class WikiController < ApplicationController
       redirect_to :action => 'index', :id => @project, :page => nil
     end
   end
+
+  def page_index
+    load_pages_grouped_by_date_without_content
+  end
   
   def preview
     page = @wiki.find_page(params[:page])
index ad4b1d2505d51493c33c9c8a2180d03cbda25e02..46e9d160b6b905b9bca7d2e878340a50362da4a2 100644 (file)
@@ -5,5 +5,5 @@
 <h3><%= l(:label_wiki) %></h3>
 
 <%= link_to l(:field_start_page), {:action => 'index', :page => nil} %><br />
-<%= link_to l(:label_index_by_title), {:action => 'special', :page => 'Page_index'} %><br />
+<%= link_to l(:label_index_by_title), {:action => 'page_index'} %><br />
 <%= link_to l(:label_index_by_date), {:action => 'special', :page => 'Date_index'} %><br />
diff --git a/app/views/wiki/page_index.html.erb b/app/views/wiki/page_index.html.erb
new file mode 100644 (file)
index 0000000..e85f83b
--- /dev/null
@@ -0,0 +1,26 @@
+<div class="contextual">
+<%= watcher_tag(@wiki, User.current) %>
+</div>
+
+<h2><%= l(:label_index_by_title) %></h2>
+
+<% if @pages.empty? %>
+<p class="nodata"><%= l(:label_no_data) %></p>
+<% end %>
+
+<%= render_page_hierarchy(@pages_by_parent_id) %>
+
+<% content_for :sidebar do %>
+  <%= render :partial => 'sidebar' %>
+<% end %>
+
+<% unless @pages.empty? %>
+<% other_formats_links do |f| %>
+       <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %>
+       <%= f.link_to('HTML', :url => {:action => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %>
+<% end %>
+<% end %>
+
+<% content_for :header_tags do %>
+<%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %>
+<% end %>
diff --git a/app/views/wiki/special_page_index.rhtml b/app/views/wiki/special_page_index.rhtml
deleted file mode 100644 (file)
index e85f83b..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<div class="contextual">
-<%= watcher_tag(@wiki, User.current) %>
-</div>
-
-<h2><%= l(:label_index_by_title) %></h2>
-
-<% if @pages.empty? %>
-<p class="nodata"><%= l(:label_no_data) %></p>
-<% end %>
-
-<%= render_page_hierarchy(@pages_by_parent_id) %>
-
-<% content_for :sidebar do %>
-  <%= render :partial => 'sidebar' %>
-<% end %>
-
-<% unless @pages.empty? %>
-<% other_formats_links do |f| %>
-       <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %>
-       <%= f.link_to('HTML', :url => {:action => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %>
-<% end %>
-<% end %>
-
-<% content_for :header_tags do %>
-<%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %>
-<% end %>
index 4bb893dae2f05a3fdc687c27e310fc2428b788b1..53a720f06060a8d7435b72c33efe9b0f60a0a494 100644 (file)
@@ -30,7 +30,8 @@ ActionController::Routing::Routes.draw do |map|
   map.with_options :controller => 'wiki' do |wiki_routes|
     wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
       wiki_views.connect 'projects/:id/wiki/export', :action => 'export'
-      wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index/i
+      wiki_views.connect 'projects/:id/wiki/page_index', :action => 'page_index'
+      wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /date_index/i
       wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil
       wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit'
       wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename'
index 9537077811067f5f9b3cfdd0c8ec72eebb3e8437..98ca41d160df10749542fd9e3d88e2a06f64e4fb 100644 (file)
@@ -111,7 +111,7 @@ Redmine::AccessControl.map do |map|
     map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
     map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
     map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member
-    map.permission :view_wiki_pages, :wiki => [:index, :special]
+    map.permission :view_wiki_pages, :wiki => [:index, :special, :page_index]
     map.permission :export_wiki_pages, :wiki => [:export]
     map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate]
     map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment]
index 6b0a6cc5ce831529f4125b92786ac5454a2f2423..37d5b8f88403237a0220409b6fea9fc4d22319b5 100644 (file)
@@ -197,7 +197,7 @@ class WikiControllerTest < ActionController::TestCase
   def test_destroy_child
     @request.session[:user_id] = 2
     post :destroy, :id => 1, :page => 'Child_1'
-    assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
+    assert_redirected_to :action => 'page_index', :id => 'ecookbook'
   end
   
   def test_destroy_parent
@@ -214,7 +214,7 @@ class WikiControllerTest < ActionController::TestCase
     assert_difference('WikiPage.count', -1) do
       post :destroy, :id => 1, :page => 'Another_page', :todo => 'nullify'
     end
-    assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
+    assert_redirected_to :action => 'page_index', :id => 'ecookbook'
     assert_nil WikiPage.find_by_id(2)
   end
   
@@ -223,7 +223,7 @@ class WikiControllerTest < ActionController::TestCase
     assert_difference('WikiPage.count', -3) do
       post :destroy, :id => 1, :page => 'Another_page', :todo => 'destroy'
     end
-    assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
+    assert_redirected_to :action => 'page_index', :id => 'ecookbook'
     assert_nil WikiPage.find_by_id(2)
     assert_nil WikiPage.find_by_id(5)
   end
@@ -233,15 +233,15 @@ class WikiControllerTest < ActionController::TestCase
     assert_difference('WikiPage.count', -1) do
       post :destroy, :id => 1, :page => 'Another_page', :todo => 'reassign', :reassign_to_id => 1
     end
-    assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
+    assert_redirected_to :action => 'page_index', :id => 'ecookbook'
     assert_nil WikiPage.find_by_id(2)
     assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent
   end
   
   def test_page_index
-    get :special, :id => 'ecookbook', :page => 'Page_index'
+    get :page_index, :id => 'ecookbook'
     assert_response :success
-    assert_template 'special_page_index'
+    assert_template 'page_index'
     pages = assigns(:pages)
     assert_not_nil pages
     assert_equal Project.find(1).wiki.pages.size, pages.size
index e20d8ad19df48782b066367830452614c63a6efe..f5cd432acff875ff3a2770e137d2f74be837e086 100644 (file)
@@ -318,8 +318,7 @@ class RoutingTest < ActionController::IntegrationTest
     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'
     should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2'
     should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
-    should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index'
-    should_route :get, "/projects/567/wiki/Page_Index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index'
+    should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'page_index', :id => '567'
     should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index'
     should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'export', :id => '567'