]> source.dussan.org Git - redmine.git/commitdiff
Refactor: rename WikiController#index to #show, it's a single resource action
authorEric Davis <edavis@littlestreamsoftware.com>
Thu, 21 Oct 2010 16:07:28 +0000 (16:07 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Thu, 21 Oct 2010 16:07:28 +0000 (16:07 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4266 e93f8b46-1217-0410-a6f0-8f06a7374b81

14 files changed:
app/controllers/wiki_controller.rb
app/helpers/application_helper.rb
app/views/wiki/_sidebar.rhtml
app/views/wiki/annotate.rhtml
app/views/wiki/date_index.html.erb
app/views/wiki/destroy.rhtml
app/views/wiki/diff.rhtml
app/views/wiki/history.rhtml
app/views/wiki/page_index.html.erb
app/views/wiki/show.rhtml
config/routes.rb
lib/redmine.rb
test/functional/wiki_controller_test.rb
test/integration/routing_test.rb

index 75902d542d34c8d13b56e6a47a29c7c0e5d9f9e7..95e1943e9ccaced353881c1360b1a0b1d2909853 100644 (file)
@@ -22,14 +22,14 @@ class WikiController < ApplicationController
   before_filter :find_wiki, :authorize
   before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy]
   
-  verify :method => :post, :only => [:destroy, :protect], :redirect_to => { :action => :index }
+  verify :method => :post, :only => [:destroy, :protect], :redirect_to => { :action => :show }
 
   helper :attachments
   include AttachmentsHelper   
   helper :watchers
-  
+
   # display a page (in editing mode if it doesn't exist)
-  def index
+  def show
     page_title = params[:page]
     @page = @wiki.find_or_new_page(page_title)
     if @page.new_record?
@@ -79,7 +79,7 @@ class WikiController < ApplicationController
         attachments = Attachment.attach_files(@page, params[:attachments])
         render_attachment_warning_if_needed(@page)
         # don't save if text wasn't changed
-        redirect_to :action => 'index', :project_id => @project, :page => @page.title
+        redirect_to :action => 'show', :project_id => @project, :page => @page.title
         return
       end
       #@content.text = params[:content][:text]
@@ -91,7 +91,7 @@ class WikiController < ApplicationController
         attachments = Attachment.attach_files(@page, params[:attachments])
         render_attachment_warning_if_needed(@page)
         call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
-        redirect_to :action => 'index', :project_id => @project, :page => @page.title
+        redirect_to :action => 'show', :project_id => @project, :page => @page.title
       end
     end
   rescue ActiveRecord::StaleObjectError
@@ -107,13 +107,13 @@ class WikiController < ApplicationController
     @original_title = @page.pretty_title
     if request.post? && @page.update_attributes(params[:wiki_page])
       flash[:notice] = l(:notice_successful_update)
-      redirect_to :action => 'index', :project_id => @project, :page => @page.title
+      redirect_to :action => 'show', :project_id => @project, :page => @page.title
     end
   end
   
   def protect
     @page.update_attribute :protected, params[:protected]
-    redirect_to :action => 'index', :project_id => @project, :page => @page.title
+    redirect_to :action => 'show', :project_id => @project, :page => @page.title
   end
 
   # show page history
@@ -176,7 +176,7 @@ class WikiController < ApplicationController
       export = render_to_string :action => 'export_multiple', :layout => false
       send_data(export, :type => 'text/html', :filename => "wiki.html")
     else
-      redirect_to :action => 'index', :project_id => @project, :page => nil
+      redirect_to :action => 'show', :project_id => @project, :page => nil
     end
   end
 
@@ -204,7 +204,7 @@ class WikiController < ApplicationController
     return render_403 unless editable?
     attachments = Attachment.attach_files(@page, params[:attachments])
     render_attachment_warning_if_needed(@page)
-    redirect_to :action => 'index', :page => @page.title
+    redirect_to :action => 'show', :page => @page.title
   end
 
 private
index 2ac301d534ccc78f43591f6e6c404a407192091a..fb4b84d7ce089f978637344d58c8c82a22cb2543 100644 (file)
@@ -182,7 +182,7 @@ module ApplicationHelper
       content << "<ul class=\"pages-hierarchy\">\n"
       pages[node].each do |page|
         content << "<li>"
-        content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'index', :project_id => page.project, :page => page.title},
+        content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :page => page.title},
                            :title => (page.respond_to?(:updated_on) ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil))
         content << "\n" + render_page_hierarchy(pages, page.id) if pages[page.id]
         content << "</li>\n"
@@ -551,7 +551,7 @@ module ApplicationHelper
             when :local; "#{title}.html"
             when :anchor; "##{title}"   # used for single-file wiki export
             else
-              url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :project_id => link_project, :page => Wiki.titleize(page), :anchor => anchor)
+              url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project, :page => Wiki.titleize(page), :anchor => anchor)
             end
           link_to((title || page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new')))
         else
index c6e5e6ab8033a6a33a9b082cf51316218d024fa5..efb24af06bc0aa2ffd243abe95857365d995cea1 100644 (file)
@@ -4,6 +4,6 @@
 
 <h3><%= l(:label_wiki) %></h3>
 
-<%= link_to l(:field_start_page), {:action => 'index', :page => nil} %><br />
+<%= 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_date), {:action => 'date_index'} %><br />
index 9d3b3282763eaebad310955c77ba3de16b51912a..1e664fb84c46c6e8572773eeab268ce1d78b0ff4 100644 (file)
@@ -6,7 +6,7 @@
 <h2><%= @page.pretty_title %></h2>
 
 <p>
-<%= l(:label_version) %> <%= link_to @annotate.content.version, :action => 'index', :page => @page.title, :version => @annotate.content.version %>
+<%= l(:label_version) %> <%= link_to @annotate.content.version, :action => 'show', :page => @page.title, :version => @annotate.content.version %>
 <em>(<%= @annotate.content.author ? @annotate.content.author.name : "anonyme" %>, <%= format_time(@annotate.content.updated_on) %>)</em>
 </p>
 
@@ -18,7 +18,7 @@
 <% @annotate.lines.each do |line| -%>
 <tr class="bloc-<%= colors[line[0]] %>">
     <th class="line-num"><%= line_num %></th>
-    <td class="revision"><%= link_to line[0], :controller => 'wiki', :action => 'index', :project_id => @project, :page => @page.title, :version => line[0] %></td>
+    <td class="revision"><%= link_to line[0], :controller => 'wiki', :action => 'show', :project_id => @project, :page => @page.title, :version => line[0] %></td>
     <td class="author"><%= h(line[1]) %></td>
     <td class="line-code"><pre><%=h line[2] %></pre></td>
 </tr>
index 957c15967d46e817fb0ac24a5af1bae29538580c..086d8f632b6fd29210fe1cb0bd0fb8361af83aa8 100644 (file)
@@ -12,7 +12,7 @@
 <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>
+    <li><%= link_to page.pretty_title, :action => 'show', :page => page.title %></li>
 <% end %>
 </ul>
 <% 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 '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 => 'index', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %>
+<%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'show', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %>
 <% end %>
index 77f20ef5e3adf9163aac9b458f67673516b81c4e..83c81fd5cda4c02d7c2bfa561e9f5edc90ce1d92 100644 (file)
@@ -15,5 +15,5 @@
 </div>
 
 <%= submit_tag l(:button_apply) %>
-<%= link_to l(:button_cancel), :controller => 'wiki', :action => 'index', :project_id => @project, :page => @page.title %>
+<%= link_to l(:button_cancel), :controller => 'wiki', :action => 'show', :project_id => @project, :page => @page.title %>
 <% end %>
index 9095be5602f6a29a1b7daf5cdf0004ded42f67bd..a9eebdb9a4b6c8ae367238605e29145f6e77d65d 100644 (file)
@@ -5,10 +5,10 @@
 <h2><%= @page.pretty_title %></h2>
 
 <p>
-<%= l(:label_version) %> <%= link_to @diff.content_from.version, :action => 'index', :page => @page.title, :version => @diff.content_from.version %>
+<%= l(:label_version) %> <%= link_to @diff.content_from.version, :action => 'show', :page => @page.title, :version => @diff.content_from.version %>
 <em>(<%= @diff.content_from.author ? @diff.content_from.author.name : "anonyme" %>, <%= format_time(@diff.content_from.updated_on) %>)</em>
 &#8594;
-<%= l(:label_version) %> <%= link_to @diff.content_to.version, :action => 'index', :page => @page.title, :version => @diff.content_to.version %>/<%= @page.content.version %>
+<%= l(:label_version) %> <%= link_to @diff.content_to.version, :action => 'show', :page => @page.title, :version => @diff.content_to.version %>/<%= @page.content.version %>
 <em>(<%= @diff.content_to.author ? @diff.content_to.author.name : "anonyme" %>, <%= format_time(@diff.content_to.updated_on) %>)</em>
 </p>
 
index 3f07d55e6ff50906e73d20ed695a72f5ee129af0..1f73fd17327d8e0201849ca12604a66f903e556e 100644 (file)
@@ -19,7 +19,7 @@
 <% line_num = 1 %>
 <% @versions.each do |ver| %>
 <tr class="<%= cycle("odd", "even") %>">
-    <td class="id"><%= link_to ver.version, :action => 'index', :page => @page.title, :version => ver.version %></td>
+    <td class="id"><%= link_to ver.version, :action => 'show', :page => @page.title, :version => ver.version %></td>
     <td class="checkbox"><%= radio_button_tag('version', ver.version, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('cbto-#{line_num+1}').checked=true;") if show_diff && (line_num < @versions.size) %></td>
     <td class="checkbox"><%= radio_button_tag('version_from', ver.version, (line_num==2), :id => "cbto-#{line_num}") if show_diff && (line_num > 1) %></td>
     <td align="center"><%= format_time(ver.updated_on) %></td>
index e85f83b91e66d0a7d4050ee6fd397e976ed459df..7e7155fda811fad750a247e220e7e1c049e4b084 100644 (file)
 
 <% 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 '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 => 'index', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %>
+<%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'show', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %>
 <% end %>
index 690e9102b96a4eefb751e83cb2f8c946b20bf446..00feab8b96f01a8b0fa7b5636ae35e97e7da3a9e 100644 (file)
 
 <% if @content.version != @page.content.version %>
     <p>    
-    <%= link_to(('&#171; ' + l(:label_previous)), :action => 'index', :page => @page.title, :version => (@content.version - 1)) + " - " if @content.version > 1 %>
+    <%= link_to(('&#171; ' + l(:label_previous)), :action => 'show', :page => @page.title, :version => (@content.version - 1)) + " - " if @content.version > 1 %>
     <%= "#{l(:label_version)} #{@content.version}/#{@page.content.version}" %>
     <%= '(' + link_to('diff', :controller => 'wiki', :action => 'diff', :page => @page.title, :version => @content.version) + ')' if @content.version > 1 %> - 
-    <%= link_to((l(:label_next) + ' &#187;'), :action => 'index', :page => @page.title, :version => (@content.version + 1)) + " - " if @content.version < @page.content.version %>
-    <%= link_to(l(:label_current_version), :action => 'index', :page => @page.title) %>
+    <%= link_to((l(:label_next) + ' &#187;'), :action => 'show', :page => @page.title, :version => (@content.version + 1)) + " - " if @content.version < @page.content.version %>
+    <%= link_to(l(:label_current_version), :action => 'show', :page => @page.title) %>
     <br />
     <em><%= @content.author ? @content.author.name : "anonyme" %>, <%= format_time(@content.updated_on) %> </em><br />
     <%=h @content.comments %>
index 764d540c800e121e98623933de7844b20af5c6cf..84d00c687a56dd61b12fbcd8c411af967d2e97ac 100644 (file)
@@ -32,7 +32,7 @@ ActionController::Routing::Routes.draw do |map|
       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/date_index', :action => 'date_index'
-      wiki_views.connect 'projects/:project_id/wiki/:page', :action => 'index', :page => nil
+      wiki_views.connect 'projects/:project_id/wiki/:page', :action => 'show', :page => nil
       wiki_views.connect 'projects/:project_id/wiki/:page/edit', :action => 'edit'
       wiki_views.connect 'projects/:project_id/wiki/:page/rename', :action => 'rename'
       wiki_views.connect 'projects/:project_id/wiki/:page/history', :action => 'history'
index 7fe09082667918661f4d2a8a956c58c2f6f262ba..d5825e00fa26b215e5018d8c9433237eba1dc8ed 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, :date_index]
+    map.permission :view_wiki_pages, :wiki => [:show, :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]
@@ -195,7 +195,7 @@ Redmine::MenuManager.map :project_menu do |menu|
   menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar
   menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
   menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural
-  menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil }, :param => :project_id,
+  menu.push :wiki, { :controller => 'wiki', :action => 'show', :page => nil }, :param => :project_id,
               :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
   menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
               :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
index 4eb33ca371e44a6c938b1b3ae6a9629aa5cf8550..cd8c3448d6b1472ccceee8423ef2a60b4a2676f2 100644 (file)
@@ -32,7 +32,7 @@ class WikiControllerTest < ActionController::TestCase
   end
   
   def test_show_start_page
-    get :index, :project_id => 'ecookbook'
+    get :show, :project_id => 'ecookbook'
     assert_response :success
     assert_template 'show'
     assert_tag :tag => 'h1', :content => /CookBook documentation/
@@ -45,7 +45,7 @@ class WikiControllerTest < ActionController::TestCase
   end
   
   def test_show_page_with_name
-    get :index, :project_id => 1, :page => 'Another_page'
+    get :show, :project_id => 1, :page => 'Another_page'
     assert_response :success
     assert_template 'show'
     assert_tag :tag => 'h1', :content => /Another page/
@@ -60,20 +60,20 @@ class WikiControllerTest < ActionController::TestCase
     page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
     page.save!
     
-    get :index, :project_id => 1, :page => 'Another_page'
+    get :show, :project_id => 1, :page => 'Another_page'
     assert_response :success
     assert_tag :tag => 'div', :attributes => {:id => 'sidebar'},
                               :content => /Side bar content for test_show_with_sidebar/
   end
   
   def test_show_unexistent_page_without_edit_right
-    get :index, :project_id => 1, :page => 'Unexistent page'
+    get :show, :project_id => 1, :page => 'Unexistent page'
     assert_response 404
   end
   
   def test_show_unexistent_page_with_edit_right
     @request.session[:user_id] = 2
-    get :index, :project_id => 1, :page => 'Unexistent page'
+    get :show, :project_id => 1, :page => 'Unexistent page'
     assert_response :success
     assert_template 'edit'
   end
@@ -85,7 +85,7 @@ class WikiControllerTest < ActionController::TestCase
                 :content => {:comments => 'Created the page',
                              :text => "h1. New page\n\nThis is a new page",
                              :version => 0}
-    assert_redirected_to :action => 'index', :project_id => 'ecookbook', :page => 'New_page'
+    assert_redirected_to :action => 'show', :project_id => 'ecookbook', :page => 'New_page'
     page = Project.find(1).wiki.find_page('New page')
     assert !page.new_record?
     assert_not_nil page.content
@@ -176,7 +176,7 @@ class WikiControllerTest < ActionController::TestCase
     post :rename, :project_id => 1, :page => 'Another_page',
                             :wiki_page => { :title => 'Another renamed page',
                                             :redirect_existing_links => 1 }
-    assert_redirected_to :action => 'index', :project_id => 'ecookbook', :page => 'Another_renamed_page'
+    assert_redirected_to :action => 'show', :project_id => 'ecookbook', :page => 'Another_renamed_page'
     wiki = Project.find(1).wiki
     # Check redirects
     assert_not_nil wiki.find_page('Another page')
@@ -188,7 +188,7 @@ class WikiControllerTest < ActionController::TestCase
     post :rename, :project_id => 1, :page => 'Another_page',
                             :wiki_page => { :title => 'Another renamed page',
                                             :redirect_existing_links => "0" }
-    assert_redirected_to :action => 'index', :project_id => 'ecookbook', :page => 'Another_renamed_page'
+    assert_redirected_to :action => 'show', :project_id => 'ecookbook', :page => 'Another_renamed_page'
     wiki = Project.find(1).wiki
     # Check that there's no redirects
     assert_nil wiki.find_page('Another page')
@@ -280,7 +280,7 @@ class WikiControllerTest < ActionController::TestCase
         get :export, :project_id => 'ecookbook'
 
         should_respond_with :redirect
-        should_redirect_to('wiki index') { {:action => 'index', :project_id => @project, :page => nil} }
+        should_redirect_to('wiki index') { {:action => 'show', :project_id => @project, :page => nil} }
       end
     end
   end
@@ -298,7 +298,7 @@ class WikiControllerTest < ActionController::TestCase
   end
   
   def test_not_found
-    get :index, :project_id => 999
+    get :show, :project_id => 999
     assert_response 404
   end
   
@@ -307,7 +307,7 @@ class WikiControllerTest < ActionController::TestCase
     assert !page.protected?
     @request.session[:user_id] = 2
     post :protect, :project_id => 1, :page => page.title, :protected => '1'
-    assert_redirected_to :action => 'index', :project_id => 'ecookbook', :page => 'Another_page'
+    assert_redirected_to :action => 'show', :project_id => 'ecookbook', :page => 'Another_page'
     assert page.reload.protected?
   end
   
@@ -316,13 +316,13 @@ class WikiControllerTest < ActionController::TestCase
     assert page.protected?
     @request.session[:user_id] = 2
     post :protect, :project_id => 1, :page => page.title, :protected => '0'
-    assert_redirected_to :action => 'index', :project_id => 'ecookbook', :page => 'CookBook_documentation'
+    assert_redirected_to :action => 'show', :project_id => 'ecookbook', :page => 'CookBook_documentation'
     assert !page.reload.protected?
   end
   
   def test_show_page_with_edit_link
     @request.session[:user_id] = 2
-    get :index, :project_id => 1
+    get :show, :project_id => 1
     assert_response :success
     assert_template 'show'
     assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
@@ -330,7 +330,7 @@ class WikiControllerTest < ActionController::TestCase
   
   def test_show_page_without_edit_link
     @request.session[:user_id] = 4
-    get :index, :project_id => 1
+    get :show, :project_id => 1
     assert_response :success
     assert_template 'show'
     assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
index 00ab7b38f7eea9ef08ba81adbc5d81e534c7606f..f44d3c94e81874ed64595a1ee459c34c3c4e5938 100644 (file)
@@ -311,8 +311,8 @@ class RoutingTest < ActionController::IntegrationTest
   end
 
   context "wiki (singular, project's pages)" do
-    should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'index', :project_id => '567'
-    should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'index', :project_id => '567', :page => 'lalala'
+    should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'show', :project_id => '567'
+    should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'show', :project_id => '567', :page => 'lalala'
     should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :project_id => '567', :page => 'my_page'
     should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :project_id => '1', :page => 'CookBook_documentation'
     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'