Skip to content

Commit

Permalink
li_link(): restore tag_attrs when doing polymorphic links
Browse files Browse the repository at this point in the history
The tag_attrs need to be part of link_to() invocation to be
able to put title (tooltip) into the rendered link correctly.

https://bugzilla.redhat.com/show_bug.cgi?id=1333955
  • Loading branch information
mzazrivec committed May 11, 2016
1 parent cdf97e8 commit 1febf24
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Expand Up @@ -927,7 +927,7 @@ def li_link(args)
tag_attrs[:onclick] = 'return miqCheckForChanges()' if check_changes
content_tag(:li) do
if args[:record] && restful_routed?(args[:record])
link_to(link_text, polymorphic_path(args[:record], :display => args[:display]))
link_to(link_text, polymorphic_path(args[:record], :display => args[:display]), tag_attrs)
else
link_to(link_text, link_params, tag_attrs)
end
Expand Down
14 changes: 12 additions & 2 deletions spec/helpers/application_helper_spec.rb
Expand Up @@ -1591,7 +1591,8 @@
:controller => 'availability_zone',
:record => FactoryGirl.create(:availability_zone),
:action => 'show_list',
:display => 'something'}
:display => 'something',
:title => 'sometitle'}
end

subject { li_link(args) }
Expand All @@ -1603,6 +1604,10 @@
it 'renders onclick correctly' do
expect(subject).to have_xpath("//a[@onclick = 'return miqCheckForChanges()']")
end

it 'renders title correctly' do
expect(subject).to have_xpath("//a[@title = 'sometitle']")
end
end

context 'with :record_id passed in as an argument' do
Expand All @@ -1611,7 +1616,8 @@
:controller => 'availability_zone',
:record_id => FactoryGirl.create(:availability_zone).id,
:action => 'show_list',
:display => 'something'}
:display => 'something',
:title => 'sometitle'}
end

subject { li_link(args) }
Expand All @@ -1623,6 +1629,10 @@
it 'renders onclick correctly' do
expect(subject).to have_xpath("//a[@onclick = 'return miqCheckForChanges()']")
end

it 'renders title correctly' do
expect(subject).to have_xpath("//a[@title = 'sometitle']")
end
end
end

Expand Down

0 comments on commit 1febf24

Please sign in to comment.