From c06c22cf2e29dc0a4a0b2b9dd67a867b370a21f9 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Mon, 18 Oct 2010 15:27:49 +0000 Subject: [PATCH] Refactor: extract method from WikiController#special git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4261 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/wiki_controller.rb | 7 ++++--- app/views/wiki/_sidebar.rhtml | 2 +- ...{special_date_index.rhtml => date_index.html.erb} | 0 config/routes.rb | 2 +- lib/redmine.rb | 2 +- test/functional/wiki_controller_test.rb | 12 ++++++++++++ test/integration/routing_test.rb | 2 +- 7 files changed, 20 insertions(+), 7 deletions(-) rename app/views/wiki/{special_date_index.rhtml => date_index.html.erb} (100%) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 7d8cb422c..2bd95bafd 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -173,9 +173,6 @@ class WikiController < ApplicationController def special page_title = params[:page].downcase case page_title - # show pages index, sorted by title - when 'date_index' - load_pages_grouped_by_date_without_content when 'export' redirect_to :action => 'export', :id => @project # Compatibility stub while refactoring return @@ -201,6 +198,10 @@ class WikiController < ApplicationController def page_index load_pages_grouped_by_date_without_content end + + def date_index + load_pages_grouped_by_date_without_content + end def preview page = @wiki.find_page(params[:page]) diff --git a/app/views/wiki/_sidebar.rhtml b/app/views/wiki/_sidebar.rhtml index 46e9d160b..c6e5e6ab8 100644 --- a/app/views/wiki/_sidebar.rhtml +++ b/app/views/wiki/_sidebar.rhtml @@ -6,4 +6,4 @@ <%= link_to l(:field_start_page), {:action => 'index', :page => nil} %>
<%= link_to l(:label_index_by_title), {:action => 'page_index'} %>
-<%= link_to l(:label_index_by_date), {:action => 'special', :page => 'Date_index'} %>
+<%= link_to l(:label_index_by_date), {:action => 'date_index'} %>
diff --git a/app/views/wiki/special_date_index.rhtml b/app/views/wiki/date_index.html.erb similarity index 100% rename from app/views/wiki/special_date_index.rhtml rename to app/views/wiki/date_index.html.erb diff --git a/config/routes.rb b/config/routes.rb index 53a720f06..7bfb5b621 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,7 +31,7 @@ ActionController::Routing::Routes.draw do |map| 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_index', :action => 'page_index' - wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /date_index/i + wiki_views.connect 'projects/:id/wiki/date_index', :action => 'date_index' 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' diff --git a/lib/redmine.rb b/lib/redmine.rb index 98ca41d16..51c865452 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -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, :page_index] + map.permission :view_wiki_pages, :wiki => [:index, :special, :page_index, :date_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] diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 37d5b8f88..7aea1b4ca 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -284,6 +284,18 @@ class WikiControllerTest < ActionController::TestCase end end end + + context "GET :date_index" do + setup do + get :date_index, :id => 'ecookbook' + end + + should_respond_with :success + should_assign_to :pages + should_assign_to :pages_by_date + should_render_template 'wiki/date_index' + + end def test_not_found get :index, :id => 999 diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index f5cd432ac..ccb15bd53 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -319,7 +319,7 @@ class RoutingTest < ActionController::IntegrationTest 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 => '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/date_index", :controller => 'wiki', :action => 'date_index', :id => '567' should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'export', :id => '567' should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page' -- 2.39.5