Project

General

Profile

Patch #26043 ยป new_wiki_page_with_parent.patch

Minoru Maeda, 2017-05-25 12:10

View differences:

app/controllers/wiki_controller.rb (working copy)
70 70
      @page.title = '' unless editable?
71 71
      @page.validate
72 72
      if @page.errors[:title].blank?
73
        path = project_wiki_page_path(@project, @page.title)
73
        path = project_wiki_page_path(:project_id => @project, :id => @page.title, :parent => params[:parent])
74 74
        respond_to do |format|
75 75
          format.html { redirect_to path }
76 76
          format.js   { render :js => "window.location = #{path.to_json}" }
app/views/wiki/_new_modal.html.erb (working copy)
1 1
<h3 class="title"><%=l(:label_wiki_page_new)%></h3>
2 2

  
3 3
<%= labelled_form_for :page, @page,
4
            :url => new_project_wiki_page_path(@project),
4
            :url => new_project_wiki_page_path(:project_id => @project, :parent => params[:parent]),
5 5
            :method => 'post',
6 6
            :remote => true do |f| %>
7 7

  
app/views/wiki/show.html.erb (working copy)
1 1
<div class="contextual">
2 2
<% if User.current.allowed_to?(:edit_wiki_pages, @project) %>
3
<%= link_to l(:label_wiki_page_new), new_project_wiki_page_path(@project), :remote => true, :class => 'icon icon-add' %>
3
<%= link_to l(:label_wiki_page_new), new_project_wiki_page_path(:project_id => @project, :parent => @page.title), :remote => true, :class => 'icon icon-add' %>
4 4
<% end %>
5 5
<% if @editable %>
6 6
<% if @content.current_version? %>
test/functional/wiki_controller_test.rb (working copy)
208 208
    assert_equal 'window.location = "/projects/ecookbook/wiki/New_Page"', response.body
209 209
  end
210 210

  
211
  def test_post_new_should_redirect_to_edit_with_parent
212
    @request.session[:user_id] = 2
213

  
214
    post :new, :params => {:project_id => 'ecookbook', :title => 'New_Page', :parent => 'Child_1'}
215
    assert_redirected_to '/projects/ecookbook/wiki/New_Page?parent=Child_1'
216
  end
217

  
211 218
  def test_post_new_with_invalid_title_should_display_errors
212 219
    @request.session[:user_id] = 2
213 220

  
    (1-1/1)