diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 75902d542..95e1943e9 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2ac301d53..fb4b84d7c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -182,7 +182,7 @@ module ApplicationHelper content << "
-<%= 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 %> (<%= @annotate.content.author ? @annotate.content.author.name : "anonyme" %>, <%= format_time(@annotate.content.updated_on) %>)
@@ -18,7 +18,7 @@ <% @annotate.lines.each do |line| -%><%=h line[2] %>
-<%= 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 %> (<%= @diff.content_from.author ? @diff.content_from.author.name : "anonyme" %>, <%= format_time(@diff.content_from.updated_on) %>) → -<%= 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 %> (<%= @diff.content_to.author ? @diff.content_to.author.name : "anonyme" %>, <%= format_time(@diff.content_to.updated_on) %>)
diff --git a/app/views/wiki/history.rhtml b/app/views/wiki/history.rhtml index 3f07d55e6..1f73fd173 100644 --- a/app/views/wiki/history.rhtml +++ b/app/views/wiki/history.rhtml @@ -19,7 +19,7 @@ <% line_num = 1 %> <% @versions.each do |ver| %>
- <%= link_to(('« ' + l(:label_previous)), :action => 'index', :page => @page.title, :version => (@content.version - 1)) + " - " if @content.version > 1 %>
+ <%= link_to(('« ' + 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) + ' »'), :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) + ' »'), :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) %>
<%= @content.author ? @content.author.name : "anonyme" %>, <%= format_time(@content.updated_on) %>
<%=h @content.comments %>
diff --git a/config/routes.rb b/config/routes.rb
index 764d540c8..84d00c687 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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'
diff --git a/lib/redmine.rb b/lib/redmine.rb
index 7fe090826..d5825e00f 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, :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
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index 4eb33ca37..cd8c3448d 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -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' }
diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb
index 00ab7b38f..f44d3c94e 100644
--- a/test/integration/routing_test.rb
+++ b/test/integration/routing_test.rb
@@ -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'