@@ -62,10 +62,12 class WikiController < ApplicationController | |||
|
62 | 62 | |
|
63 | 63 | def new |
|
64 | 64 | @page = WikiPage.new(:wiki => @wiki, :title => params[:title]) |
|
65 |
unless User.current.allowed_to?(:edit_wiki_pages, @project) |
|
|
65 | unless User.current.allowed_to?(:edit_wiki_pages, @project) | |
|
66 | 66 | render_403 |
|
67 | return | |
|
67 | 68 | end |
|
68 | 69 | if request.post? |
|
70 | @page.title = '' unless editable? | |
|
69 | 71 | @page.validate |
|
70 | 72 | if @page.errors[:title].blank? |
|
71 | 73 | path = project_wiki_page_path(@project, @page.title) |
@@ -223,6 +223,15 class WikiControllerTest < ActionController::TestCase | |||
|
223 | 223 | assert_select_error 'Title has already been taken' |
|
224 | 224 | end |
|
225 | 225 | |
|
226 | def test_post_new_with_protected_title_should_display_errors | |
|
227 | Role.find(1).remove_permission!(:protect_wiki_pages) | |
|
228 | @request.session[:user_id] = 2 | |
|
229 | ||
|
230 | post :new, :params => {:project_id => 'ecookbook', :title => 'Sidebar'} | |
|
231 | assert_response :success | |
|
232 | assert_select_error /Title/ | |
|
233 | end | |
|
234 | ||
|
226 | 235 | def test_post_new_xhr_with_invalid_title_should_display_errors |
|
227 | 236 | @request.session[:user_id] = 2 |
|
228 | 237 |
General Comments 0
You need to be logged in to leave comments.
Login now