Skip to content

Commit

Permalink
Refactor: extract method from WikiController#special
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4261 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
edavis10 committed Oct 18, 2010
1 parent fef21d5 commit c06c22c
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 deletions.
7 changes: 4 additions & 3 deletions app/controllers/wiki_controller.rb
Expand Up @@ -173,9 +173,6 @@ def destroy
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
Expand All @@ -201,6 +198,10 @@ def export
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])
Expand Down
2 changes: 1 addition & 1 deletion app/views/wiki/_sidebar.rhtml
Expand Up @@ -6,4 +6,4 @@

<%= link_to l(:field_start_page), {:action => 'index', :page => nil} %><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 />
<%= link_to l(:label_index_by_date), {:action => 'date_index'} %><br />
File renamed without changes.
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -31,7 +31,7 @@
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'
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine.rb
Expand Up @@ -111,7 +111,7 @@
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]
Expand Down
12 changes: 12 additions & 0 deletions test/functional/wiki_controller_test.rb
Expand Up @@ -284,6 +284,18 @@ def test_page_index
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
Expand Down
2 changes: 1 addition & 1 deletion test/integration/routing_test.rb
Expand Up @@ -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'
Expand Down

0 comments on commit c06c22c

Please sign in to comment.