summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-11-06 14:30:32 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-11-06 14:30:32 +0000
commit666c54e86c2a8532ff9330d7ce4e9e7d3a44b173 (patch)
treeb7d8fde2ea2b7f3dd9277bb32be5f931836be1fe
parentf79a6f701a6bd0ef086fbdb40c2bb7622f048afc (diff)
downloadredmine-666c54e86c2a8532ff9330d7ce4e9e7d3a44b173.tar.gz
redmine-666c54e86c2a8532ff9330d7ce4e9e7d3a44b173.zip
Adds a combo to select parent on wiki page rename (#5136).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4375 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/wiki_helper.rb2
-rw-r--r--app/views/wiki/rename.rhtml2
-rw-r--r--test/functional/wiki_controller_test.rb48
3 files changed, 50 insertions, 2 deletions
diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb
index c25064616..19e252bcb 100644
--- a/app/helpers/wiki_helper.rb
+++ b/app/helpers/wiki_helper.rb
@@ -24,7 +24,7 @@ module WikiHelper
attrs << " selected='selected'" if selected == page
indent = (level > 0) ? ('&nbsp;' * level * 2 + '&#187; ') : nil
- s << "<option value='#{page.id}'>#{indent}#{h page.pretty_title}</option>\n" +
+ s << "<option #{attrs}>#{indent}#{h page.pretty_title}</option>\n" +
wiki_page_options_for_select(pages, selected, page, level + 1)
end
s
diff --git a/app/views/wiki/rename.rhtml b/app/views/wiki/rename.rhtml
index 260f9af8b..f94b8bc3d 100644
--- a/app/views/wiki/rename.rhtml
+++ b/app/views/wiki/rename.rhtml
@@ -6,7 +6,7 @@
<div class="box">
<p><%= f.text_field :title, :required => true, :size => 100 %></p>
<p><%= f.check_box :redirect_existing_links %></p>
-<p><%= f.text_field :parent_title, :size => 100 %></p>
+<p><%= f.select :parent_id, "<option value=''></option>" + wiki_page_options_for_select(@wiki.pages.all(:include => :parent) - @page.self_and_descendants, @page.parent), :label => :field_parent_title %></p>
</div>
<%= submit_tag l(:button_rename) %>
<% end %>
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index 4273dddd0..74e9e11b6 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -170,6 +170,38 @@ class WikiControllerTest < ActionController::TestCase
:child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/ },
:child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
end
+
+ def test_get_rename
+ @request.session[:user_id] = 2
+ get :rename, :project_id => 1, :id => 'Another_page'
+ assert_response :success
+ assert_template 'rename'
+ assert_tag 'option',
+ :attributes => {:value => ''},
+ :content => '',
+ :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
+ assert_no_tag 'option',
+ :attributes => {:selected => 'selected'},
+ :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
+ end
+
+ def test_get_rename_child_page
+ @request.session[:user_id] = 2
+ get :rename, :project_id => 1, :id => 'Child_1'
+ assert_response :success
+ assert_template 'rename'
+ assert_tag 'option',
+ :attributes => {:value => ''},
+ :content => '',
+ :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
+ assert_tag 'option',
+ :attributes => {:value => '2', :selected => 'selected'},
+ :content => /Another page/,
+ :parent => {
+ :tag => 'select',
+ :attributes => {:name => 'wiki_page[parent_id]'}
+ }
+ end
def test_rename_with_redirect
@request.session[:user_id] = 2
@@ -194,6 +226,22 @@ class WikiControllerTest < ActionController::TestCase
assert_nil wiki.find_page('Another page')
end
+ def test_rename_with_parent_assignment
+ @request.session[:user_id] = 2
+ post :rename, :project_id => 1, :id => 'Another_page',
+ :wiki_page => { :title => 'Another page', :redirect_existing_links => "0", :parent_id => '4' }
+ assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page'
+ assert_equal WikiPage.find(4), WikiPage.find_by_title('Another_page').parent
+ end
+
+ def test_rename_with_parent_unassignment
+ @request.session[:user_id] = 2
+ post :rename, :project_id => 1, :id => 'Child_1',
+ :wiki_page => { :title => 'Child 1', :redirect_existing_links => "0", :parent_id => '' }
+ assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Child_1'
+ assert_nil WikiPage.find_by_title('Child_1').parent
+ end
+
def test_destroy_child
@request.session[:user_id] = 2
delete :destroy, :project_id => 1, :id => 'Child_1'