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

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

index 7d8cb422c635d1aedbfc8fbcca4bdac3af99976e..2bd95bafd5f57c10db81642c107622a7fec01607 100644 (file)
@@ -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])
index 46e9d160b6b905b9bca7d2e878340a50362da4a2..c6e5e6ab8033a6a33a9b082cf51316218d024fa5 100644 (file)
@@ -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 />
diff --git a/app/views/wiki/date_index.html.erb b/app/views/wiki/date_index.html.erb
new file mode 100644 (file)
index 0000000..957c159
--- /dev/null
@@ -0,0 +1,33 @@
+<div class="contextual">
+<%= watcher_tag(@wiki, User.current) %>
+</div>
+
+<h2><%= l(:label_index_by_date) %></h2>
+
+<% if @pages.empty? %>
+<p class="nodata"><%= l(:label_no_data) %></p>
+<% end %>
+
+<% @pages_by_date.keys.sort.reverse.each do |date| %>
+<h3><%= format_date(date) %></h3>
+<ul>
+<% @pages_by_date[date].each do |page| %>
+    <li><%= link_to page.pretty_title, :action => 'index', :page => page.title %></li>
+<% end %>
+</ul>
+<% end %>
+
+<% 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_date_index.rhtml b/app/views/wiki/special_date_index.rhtml
deleted file mode 100644 (file)
index 957c159..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<div class="contextual">
-<%= watcher_tag(@wiki, User.current) %>
-</div>
-
-<h2><%= l(:label_index_by_date) %></h2>
-
-<% if @pages.empty? %>
-<p class="nodata"><%= l(:label_no_data) %></p>
-<% end %>
-
-<% @pages_by_date.keys.sort.reverse.each do |date| %>
-<h3><%= format_date(date) %></h3>
-<ul>
-<% @pages_by_date[date].each do |page| %>
-    <li><%= link_to page.pretty_title, :action => 'index', :page => page.title %></li>
-<% end %>
-</ul>
-<% end %>
-
-<% 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 53a720f06060a8d7435b72c33efe9b0f60a0a494..7bfb5b621966e3ad123ebd88fa1ba8f98bda271b 100644 (file)
@@ -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'
index 98ca41d160df10749542fd9e3d88e2a06f64e4fb..51c865452cfd273c879bfdffa6551e7e1ea58d6f 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, :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]
index 37d5b8f88403237a0220409b6fea9fc4d22319b5..7aea1b4caf6709f2c4b68d2bdd994c163738ccbf 100644 (file)
@@ -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
index f5cd432acff875ff3a2770e137d2f74be837e086..ccb15bd535113cb95cc7dbcf43713af3f23b6383 100644 (file)
@@ -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'