diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b40992cc0c5..1594eacf015 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 243487f070a..9c94c7ac12e 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -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("
  • Projects (1)
  • ") + end + end + end end