Skip to content

Commit

Permalink
Add test for link href
Browse files Browse the repository at this point in the history
  • Loading branch information
rbtgr authored and Redmine Patch Meetup committed Feb 5, 2021
1 parent b1951bc commit ad85fdc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/views/wiki/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<%= link_to_if_authorized(l(:button_unlock), {:action => 'protect', :id => @page.title, :protected => 0}, :method => :post, :class => 'icon icon-unlock') if @page.protected? %>
<%= link_to_if_authorized(l(:button_rename), {:action => 'rename', :id => @page.title}, :class => 'icon icon-move') %>
<% @redirects_to_self.map { |redirect| %>
<%= link_to("Delete redirect from #{WikiPage.pretty_title(redirect.title)}", {:controller => 'wiki_redirects', :action => 'destroy', :project_id => @project.id, :wiki_page_id => @page.title, :id => redirect.id}, :method => :delete, :class => 'icon icon-link-break') %>
<%= 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') %>
<% } %>
<%= 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') %>
<% else %>
Expand Down
16 changes: 10 additions & 6 deletions test/functional/wiki_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,18 @@ def test_show_delete_redirect_links
wiki_page.title = new_title
wiki_page.save

get :show, :params => {:project_id => 1, :id => new_title}
redirect1 = WikiRedirect.find_by(title: 'CookBook_documentation', redirects_to: 'New_Cookbook')
redirect2 = WikiRedirect.find_by(title: 'Old_Cookbook', redirects_to: 'New_Cookbook')

get :show, :params => {:project_id => 'ecookbook', :id => new_title}

assert_select '.drdn-items' do
# TODO: Assert correct link
# assert_select 'a.icon-link-break[href=?]', '/projects/ecookbook/wiki/redirects/', text: 'Delete redirect from CookBook documentation'
# assert_select 'a.icon-link-break[href=?]', '/projects/ecookbook/wiki/redirects/', text: 'Delete redirect from Old Cookbook'
assert_select 'a.icon-link-break', text: 'Delete redirect from CookBook documentation'
assert_select 'a.icon-link-break', text: 'Delete redirect from Old Cookbook'
assert_select 'a.icon-link-break[href=?]',
"/projects/ecookbook/wiki/#{new_title}/redirects/#{redirect1.id}",
text: 'Delete redirect from CookBook documentation'
assert_select 'a.icon-link-break[href=?]',
"/projects/ecookbook/wiki/#{new_title}/redirects/#{redirect2.id}",
text: 'Delete redirect from Old Cookbook'
end
end

Expand Down

0 comments on commit ad85fdc

Please sign in to comment.