Skip to content

Commit

Permalink
Merge pull request #10205 from h-kataria/pr_8866_to_darga
Browse files Browse the repository at this point in the history
[DARGA] Fix Relationship links for a Middleware Provider
  • Loading branch information
chessbyte committed Aug 3, 2016
2 parents 26691b9 + 7a42fce commit 3786eb6
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 3786eb6

Please sign in to comment.