Skip to content

Commit 9a03da7

Browse files
kfischer-okarinRedmine Patch Meetup
authored andcommitted
Show links to delete redirect (no function)
1 parent f653a8f commit 9a03da7

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
@@ -233,6 +233,28 @@ def test_show_protected_page_shoud_show_locked_badge
233233
end
234234
end
235235

236+
def test_show_delete_redirect_links
237+
@request.session[:user_id] = 2
238+
239+
wiki_page = WikiPage.find_by(title: 'CookBook_documentation')
240+
second_title = 'Old_Cookbook'
241+
wiki_page.title = second_title
242+
wiki_page.save
243+
244+
new_title = 'New_Cookbook'
245+
wiki_page.title = new_title
246+
wiki_page.save
247+
248+
get :show, :params => {:project_id => 'ecookbook', :id => new_title}
249+
250+
assert_select '.drdn-items' do
251+
assert_select 'a.icon-link-break',
252+
text: 'Delete redirect from CookBook documentation'
253+
assert_select 'a.icon-link-break',
254+
text: 'Delete redirect from Old Cookbook'
255+
end
256+
end
257+
236258
def test_get_new
237259
@request.session[:user_id] = 2
238260

0 commit comments

Comments
 (0)