]> source.dussan.org Git - redmine.git/commitdiff
Refactor: Rename WikiController#page_index to #index
authorEric Davis <edavis@littlestreamsoftware.com>
Mon, 25 Oct 2010 16:16:46 +0000 (16:16 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Mon, 25 Oct 2010 16:16:46 +0000 (16:16 +0000)
index is the action that should list a collection of records, which is
what #page_index does.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4290 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 1c42ab5cd97d002f11193cf79d1b13318a4eab31..c7b866239ae82159bf994d6387a2b4649d2658ac 100644 (file)
 
 require 'diff'
 
+# The WikiController follows the Rails REST controller pattern but with
+# a few differences
+#
+# * index - shows a list of WikiPages grouped by page or date
+# * new - not used
+# * create - not used
+# * show - will also show the form for creating a new wiki page
+# * edit - used to edit an existing or new page
+# * update - used to save a wiki page update to the database, including new pages
+# * destroy - normal
+#
+# Other member and collection methods are also used
+#
+# TODO: still being worked on
 class WikiController < ApplicationController
   default_search_scope :wiki_pages
   before_filter :find_wiki, :authorize
@@ -28,6 +42,11 @@ class WikiController < ApplicationController
   include AttachmentsHelper   
   helper :watchers
 
+  # List of pages, sorted alphabetically and by parent (hierarchy)
+  def index
+    load_pages_grouped_by_date_without_content
+  end
+
   # display a page (in editing mode if it doesn't exist)
   def show
     page_title = params[:page]
@@ -180,7 +199,7 @@ class WikiController < ApplicationController
       end
     end
     @page.destroy
-    redirect_to :action => 'page_index', :project_id => @project
+    redirect_to :action => 'index', :project_id => @project
   end
 
   # Export wiki to a single html file
@@ -194,10 +213,6 @@ class WikiController < ApplicationController
     end
   end
 
-  def page_index
-    load_pages_grouped_by_date_without_content
-  end
-
   def date_index
     load_pages_grouped_by_date_without_content
   end
index efb24af06bc0aa2ffd243abe95857365d995cea1..7f60825aad30da5f20bffbe53f88229fc1af9468 100644 (file)
@@ -5,5 +5,5 @@
 <h3><%= l(:label_wiki) %></h3>
 
 <%= link_to l(:field_start_page), {:action => 'show', :page => nil} %><br />
-<%= link_to l(:label_index_by_title), {:action => 'page_index'} %><br />
+<%= link_to l(:label_index_by_title), {:action => 'index'} %><br />
 <%= link_to l(:label_index_by_date), {:action => 'date_index'} %><br />
diff --git a/app/views/wiki/index.html.erb b/app/views/wiki/index.html.erb
new file mode 100644 (file)
index 0000000..7e7155f
--- /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 => 'show', :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 => 'show', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %>
+<% end %>
diff --git a/app/views/wiki/page_index.html.erb b/app/views/wiki/page_index.html.erb
deleted file mode 100644 (file)
index 7e7155f..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 => 'show', :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 => 'show', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %>
-<% end %>
index 511e6dc29d556027914b38ea464cf410d5e66ca4..5ca9d86d1f56a7e63f3e7c958881c55f196be9d8 100644 (file)
@@ -30,7 +30,7 @@ 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/:project_id/wiki/export', :action => 'export'
-      wiki_views.connect 'projects/:project_id/wiki/page_index', :action => 'page_index'
+      wiki_views.connect 'projects/:project_id/wiki/index', :action => 'index'
       wiki_views.connect 'projects/:project_id/wiki/date_index', :action => 'date_index'
       wiki_views.connect 'projects/:project_id/wiki/:page', :action => 'show', :page => nil
       wiki_views.connect 'projects/:project_id/wiki/:page/edit', :action => 'edit'
index 1a4b581ceaf90f55ad1df51202a18ae383b167fe..e813950ce8b5e13dfd8d2ed19a12b9ec494b23c8 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 => [:show, :special, :page_index, :date_index]
+    map.permission :view_wiki_pages, :wiki => [:index, :show, :special, :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, :update, :preview, :add_attachment]
index 61e265925a0489b727fb066980630ef3d3c1109c..fecde6159c980a167e8525474ecf1361bec2c978 100644 (file)
@@ -197,7 +197,7 @@ class WikiControllerTest < ActionController::TestCase
   def test_destroy_child
     @request.session[:user_id] = 2
     post :destroy, :project_id => 1, :page => 'Child_1'
-    assert_redirected_to :action => 'page_index', :project_id => 'ecookbook'
+    assert_redirected_to :action => 'index', :project_id => 'ecookbook'
   end
   
   def test_destroy_parent
@@ -214,7 +214,7 @@ class WikiControllerTest < ActionController::TestCase
     assert_difference('WikiPage.count', -1) do
       post :destroy, :project_id => 1, :page => 'Another_page', :todo => 'nullify'
     end
-    assert_redirected_to :action => 'page_index', :project_id => 'ecookbook'
+    assert_redirected_to :action => 'index', :project_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, :project_id => 1, :page => 'Another_page', :todo => 'destroy'
     end
-    assert_redirected_to :action => 'page_index', :project_id => 'ecookbook'
+    assert_redirected_to :action => 'index', :project_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, :project_id => 1, :page => 'Another_page', :todo => 'reassign', :reassign_to_id => 1
     end
-    assert_redirected_to :action => 'page_index', :project_id => 'ecookbook'
+    assert_redirected_to :action => 'index', :project_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 :page_index, :project_id => 'ecookbook'
+  def test_index
+    get :index, :project_id => 'ecookbook'
     assert_response :success
-    assert_template 'page_index'
+    assert_template 'index'
     pages = assigns(:pages)
     assert_not_nil pages
     assert_equal Project.find(1).wiki.pages.size, pages.size
index ea8c71b0af2143d594407fbb5400009a45568ab5..c749f51e427928b20f6cb2ae25e8a886476d1c61 100644 (file)
@@ -318,7 +318,7 @@ class RoutingTest < ActionController::IntegrationTest
     should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1", :controller => 'wiki', :action => 'diff', :project_id => '1', :page => 'CookBook_documentation', :version => '2', :version_from => '1'
     should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :project_id => '1', :page => 'CookBook_documentation', :version => '2'
     should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :page => 'ladida'
-    should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'page_index', :project_id => '567'
+    should_route :get, "/projects/567/wiki/index", :controller => 'wiki', :action => 'index', :project_id => '567'
     should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'date_index', :project_id => '567'
     should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'export', :project_id => '567'