Index: app/controllers/wiki_controller.rb =================================================================== --- app/controllers/wiki_controller.rb (revision 16559) +++ app/controllers/wiki_controller.rb (working copy) @@ -70,7 +70,7 @@ @page.title = '' unless editable? @page.validate if @page.errors[:title].blank? - path = project_wiki_page_path(@project, @page.title) + path = project_wiki_page_path(:project_id => @project, :id => @page.title, :parent => params[:parent]) respond_to do |format| format.html { redirect_to path } format.js { render :js => "window.location = #{path.to_json}" } Index: app/views/wiki/_new_modal.html.erb =================================================================== --- app/views/wiki/_new_modal.html.erb (revision 16559) +++ app/views/wiki/_new_modal.html.erb (working copy) @@ -1,7 +1,7 @@

<%=l(:label_wiki_page_new)%>

<%= labelled_form_for :page, @page, - :url => new_project_wiki_page_path(@project), + :url => new_project_wiki_page_path(:project_id => @project, :parent => params[:parent]), :method => 'post', :remote => true do |f| %> Index: app/views/wiki/show.html.erb =================================================================== --- app/views/wiki/show.html.erb (revision 16559) +++ app/views/wiki/show.html.erb (working copy) @@ -1,6 +1,6 @@
<% if User.current.allowed_to?(:edit_wiki_pages, @project) %> -<%= link_to l(:label_wiki_page_new), new_project_wiki_page_path(@project), :remote => true, :class => 'icon icon-add' %> +<%= link_to l(:label_wiki_page_new), new_project_wiki_page_path(:project_id => @project, :parent => @page.title), :remote => true, :class => 'icon icon-add' %> <% end %> <% if @editable %> <% if @content.current_version? %> Index: test/functional/wiki_controller_test.rb =================================================================== --- test/functional/wiki_controller_test.rb (revision 16559) +++ test/functional/wiki_controller_test.rb (working copy) @@ -208,6 +208,13 @@ assert_equal 'window.location = "/projects/ecookbook/wiki/New_Page"', response.body end + def test_post_new_should_redirect_to_edit_with_parent + @request.session[:user_id] = 2 + + post :new, :params => {:project_id => 'ecookbook', :title => 'New_Page', :parent => 'Child_1'} + assert_redirected_to '/projects/ecookbook/wiki/New_Page?parent=Child_1' + end + def test_post_new_with_invalid_title_should_display_errors @request.session[:user_id] = 2