Skip to content

Commit

Permalink
Fix Relationship links for a Middleware Provider
Browse files Browse the repository at this point in the history
The Middleware Provider controller (ems_middleware) does not support RESTful routing yet, therefore the Relationship links should be routed using :controller, :action and :id
cherry-picking changes from ManageIQ#8866

Fixes ManageIQ#8803
https://bugzilla.redhat.com/show_bug.cgi?id=1361844
  • Loading branch information
h-kataria committed Aug 2, 2016
1 parent 112e83e commit 7a42fce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/helpers/application_helper.rb
Expand Up @@ -84,9 +84,18 @@ def multiple_relationship_link(record, table_name)
end
else
out = content_tag(:li) do
link_to("#{plural} (#{count})",
polymorphic_path(@record, :display => table_name.to_s.pluralize),
:title => _("Show %{plural_linked_name}") % {:plural_linked_name => plural})
if restful_routed?(record)
link_to("#{plural} (#{count})",
polymorphic_path(record, :display => table_name.to_s.pluralize),
:title => _("Show %{plural_linked_name}") % {:plural_linked_name => plural})
else
link_to("#{plural} (#{count})",
{:controller => controller_name,
:action => 'show',
:id => record.id,
:display => table_name.to_s.pluralize},
:title => _("Show %{plural_linked_name}") % {:plural_linked_name => plural})
end
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions spec/helpers/application_helper_spec.rb
Expand Up @@ -1701,4 +1701,14 @@
).to eq('host_services')
end
end

describe "#multiple_relationship_link" do
context "When record is a Container Provider" do
it "Uses polymorphic_path for the show action" do
ems = FactoryGirl.create(:ems_kubernetes)
ContainerProject.create(:ext_management_system => ems, :name => "Test Project")
expect(helper.multiple_relationship_link(ems, "container_project")).to eq("<li><a title=\"Show Projects\" href=\"/ems_container/#{ems.id}?display=container_projects\">Projects (1)</a></li>")
end
end
end
end

0 comments on commit 7a42fce

Please sign in to comment.