]> source.dussan.org Git - redmine.git/commitdiff
Merged r15749 (#23700).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 31 Aug 2016 16:56:31 +0000 (16:56 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 31 Aug 2016 16:56:31 +0000 (16:56 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@15771 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/wiki_controller.rb
test/functional/wiki_controller_test.rb

index 10fd099e023278f79138e33af341e243c8f04c0d..36a9b87418dc8a49314a5a6f22a0772a8d2d9c62 100644 (file)
@@ -62,10 +62,12 @@ class WikiController < ApplicationController
 
   def new
     @page = WikiPage.new(:wiki => @wiki, :title => params[:title])
-    unless User.current.allowed_to?(:edit_wiki_pages, @project) && editable?
+    unless User.current.allowed_to?(:edit_wiki_pages, @project)
       render_403
+      return
     end
     if request.post?
+      @page.title = '' unless editable?
       @page.validate
       if @page.errors[:title].blank?
         path = project_wiki_page_path(@project, @page.title)
index cd3bf0a76eeae61d1f7e6ea2f7a6f086fe079d9d..8012f97a9232899313f917cef82705429db8bb02 100644 (file)
@@ -223,6 +223,15 @@ class WikiControllerTest < ActionController::TestCase
     assert_select_error 'Title has already been taken'
   end
 
+  def test_post_new_with_protected_title_should_display_errors
+    Role.find(1).remove_permission!(:protect_wiki_pages)
+    @request.session[:user_id] = 2
+
+    post :new, :params => {:project_id => 'ecookbook', :title => 'Sidebar'}
+    assert_response :success
+    assert_select_error /Title/
+  end
+
   def test_post_new_xhr_with_invalid_title_should_display_errors
     @request.session[:user_id] = 2