Skip to content

Commit bc6b9aa

Browse files
Show links to delete redirect (no function)
1 parent fac2633 commit bc6b9aa

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

app/controllers/wiki_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def show
118118
@content.current_version? &&
119119
Redmine::WikiFormatting.supports_section_edit?
120120

121+
@redirects_to_self = WikiRedirect.where(:redirects_to => @page.title, :redirects_to_wiki_id => @page.wiki_id)
121122
respond_to do |format|
122123
format.html
123124
format.api

app/views/wiki/show.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<%= link_to_if_authorized(l(:button_lock), {:action => 'protect', :id => @page.title, :protected => 1}, :method => :post, :class => 'icon icon-lock') if !@page.protected? %>
1616
<%= link_to_if_authorized(l(:button_unlock), {:action => 'protect', :id => @page.title, :protected => 0}, :method => :post, :class => 'icon icon-unlock') if @page.protected? %>
1717
<%= link_to_if_authorized(l(:button_rename), {:action => 'rename', :id => @page.title}, :class => 'icon icon-move') %>
18+
<% @redirects_to_self.map { |redirect| %>
19+
<%= link_to("Delete redirect from #{WikiPage.pretty_title(redirect.title)}", '', :class => 'icon icon-link-break') %>
20+
<% } %>
1821
<%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :id => @page.title}, :method => :delete, :data => {:confirm => l(:text_are_you_sure)}, :class => 'icon icon-del') %>
1922
<% else %>
2023
<%= link_to_if_authorized(l(:button_rollback), {:action => 'edit', :id => @page.title, :version => @content.version }, :class => 'icon icon-cancel') %>

test/functional/wiki_controller_test.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,28 @@ def test_show_protected_page_shoud_show_locked_badge
186186
end
187187
end
188188

189+
def test_show_delete_redirect_links
190+
@request.session[:user_id] = 2
191+
192+
wiki_page = WikiPage.find_by(title: 'CookBook_documentation')
193+
second_title = 'Old_Cookbook'
194+
wiki_page.title = second_title
195+
wiki_page.save
196+
197+
new_title = 'New_Cookbook'
198+
wiki_page.title = new_title
199+
wiki_page.save
200+
201+
get :show, :params => {:project_id => 'ecookbook', :id => new_title}
202+
203+
assert_select '.drdn-items' do
204+
assert_select 'a.icon-link-break',
205+
text: 'Delete redirect from CookBook documentation'
206+
assert_select 'a.icon-link-break',
207+
text: 'Delete redirect from Old Cookbook'
208+
end
209+
end
210+
189211
def test_get_new
190212
@request.session[:user_id] = 2
191213

0 commit comments

Comments
 (0)