##// END OF EJS Templates
Adds a combo to select parent on wiki page rename (#5136)....
Jean-Philippe Lang -
r4261:666c54e86c2a
parent child
Show More
@@ -24,7 +24,7 module WikiHelper
24 attrs << " selected='selected'" if selected == page
24 attrs << " selected='selected'" if selected == page
25 indent = (level > 0) ? ('&nbsp;' * level * 2 + '&#187; ') : nil
25 indent = (level > 0) ? ('&nbsp;' * level * 2 + '&#187; ') : nil
26
26
27 s << "<option value='#{page.id}'>#{indent}#{h page.pretty_title}</option>\n" +
27 s << "<option #{attrs}>#{indent}#{h page.pretty_title}</option>\n" +
28 wiki_page_options_for_select(pages, selected, page, level + 1)
28 wiki_page_options_for_select(pages, selected, page, level + 1)
29 end
29 end
30 s
30 s
@@ -6,7 +6,7
6 <div class="box">
6 <div class="box">
7 <p><%= f.text_field :title, :required => true, :size => 100 %></p>
7 <p><%= f.text_field :title, :required => true, :size => 100 %></p>
8 <p><%= f.check_box :redirect_existing_links %></p>
8 <p><%= f.check_box :redirect_existing_links %></p>
9 <p><%= f.text_field :parent_title, :size => 100 %></p>
9 <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>
10 </div>
10 </div>
11 <%= submit_tag l(:button_rename) %>
11 <%= submit_tag l(:button_rename) %>
12 <% end %>
12 <% end %>
@@ -170,6 +170,38 class WikiControllerTest < ActionController::TestCase
170 :child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/ },
170 :child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/ },
171 :child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
171 :child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
172 end
172 end
173
174 def test_get_rename
175 @request.session[:user_id] = 2
176 get :rename, :project_id => 1, :id => 'Another_page'
177 assert_response :success
178 assert_template 'rename'
179 assert_tag 'option',
180 :attributes => {:value => ''},
181 :content => '',
182 :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
183 assert_no_tag 'option',
184 :attributes => {:selected => 'selected'},
185 :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
186 end
187
188 def test_get_rename_child_page
189 @request.session[:user_id] = 2
190 get :rename, :project_id => 1, :id => 'Child_1'
191 assert_response :success
192 assert_template 'rename'
193 assert_tag 'option',
194 :attributes => {:value => ''},
195 :content => '',
196 :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
197 assert_tag 'option',
198 :attributes => {:value => '2', :selected => 'selected'},
199 :content => /Another page/,
200 :parent => {
201 :tag => 'select',
202 :attributes => {:name => 'wiki_page[parent_id]'}
203 }
204 end
173
205
174 def test_rename_with_redirect
206 def test_rename_with_redirect
175 @request.session[:user_id] = 2
207 @request.session[:user_id] = 2
@@ -194,6 +226,22 class WikiControllerTest < ActionController::TestCase
194 assert_nil wiki.find_page('Another page')
226 assert_nil wiki.find_page('Another page')
195 end
227 end
196
228
229 def test_rename_with_parent_assignment
230 @request.session[:user_id] = 2
231 post :rename, :project_id => 1, :id => 'Another_page',
232 :wiki_page => { :title => 'Another page', :redirect_existing_links => "0", :parent_id => '4' }
233 assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page'
234 assert_equal WikiPage.find(4), WikiPage.find_by_title('Another_page').parent
235 end
236
237 def test_rename_with_parent_unassignment
238 @request.session[:user_id] = 2
239 post :rename, :project_id => 1, :id => 'Child_1',
240 :wiki_page => { :title => 'Child 1', :redirect_existing_links => "0", :parent_id => '' }
241 assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Child_1'
242 assert_nil WikiPage.find_by_title('Child_1').parent
243 end
244
197 def test_destroy_child
245 def test_destroy_child
198 @request.session[:user_id] = 2
246 @request.session[:user_id] = 2
199 delete :destroy, :project_id => 1, :id => 'Child_1'
247 delete :destroy, :project_id => 1, :id => 'Child_1'
General Comments 0
You need to be logged in to leave comments. Login now