Skip to content

Commit ff0db9f

Browse files
Add functionality to delete link
1 parent 07ed481 commit ff0db9f

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

app/views/wiki/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
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') %>
1818
<% @redirects_to_self.map { |redirect| %>
19-
<%= link_to("Delete redirect from #{WikiPage.pretty_title(redirect.title)}", '', :class => 'icon icon-link-break') %>
19+
<%= link_to("Delete redirect from #{WikiPage.pretty_title(redirect.title)}", {:controller => 'wiki_redirects', :action => 'destroy', :project_id => @project.identifier, :wiki_page_id => @page.title, :id => redirect.id}, :method => :delete, :class => 'icon icon-link-break') %>
2020
<% } %>
2121
<%= 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') %>
2222
<% else %>

test/functional/wiki_controller_test.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,20 +190,23 @@ def test_show_delete_redirect_links
190190
@request.session[:user_id] = 2
191191

192192
wiki_page = WikiPage.find_by(title: 'CookBook_documentation')
193-
second_title = 'Old_Cookbook'
194-
wiki_page.title = second_title
193+
wiki_page.title = 'Old_Cookbook'
195194
wiki_page.save
196195

197-
new_title = 'New_Cookbook'
198-
wiki_page.title = new_title
196+
wiki_page.title = 'New_Cookbook'
199197
wiki_page.save
200198

201-
get :show, :params => {:project_id => 'ecookbook', :id => new_title}
199+
cookbook_doc_redirect = WikiRedirect.find_by(title: 'CookBook_documentation', redirects_to: 'New_Cookbook')
200+
old_cookbook_redirect = WikiRedirect.find_by(title: 'Old_Cookbook', redirects_to: 'New_Cookbook')
201+
202+
get :show, :params => {:project_id => 'ecookbook', :id => 'New_Cookbook'}
202203

203204
assert_select '.drdn-items' do
204-
assert_select 'a.icon-link-break',
205+
assert_select 'a.icon-link-break[href=?]',
206+
"/projects/ecookbook/wiki/New_Cookbook/redirects/#{cookbook_doc_redirect.id}",
205207
text: 'Delete redirect from CookBook documentation'
206-
assert_select 'a.icon-link-break',
208+
assert_select 'a.icon-link-break[href=?]',
209+
"/projects/ecookbook/wiki/New_Cookbook/redirects/#{old_cookbook_redirect.id}",
207210
text: 'Delete redirect from Old Cookbook'
208211
end
209212
end

0 commit comments

Comments
 (0)