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)
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