Project

General

Profile

« Previous | Next » 

Revision 6e92e9a5

Added by Sam Kottler almost 12 years ago

  • ID 6e92e9a55bf4eea29fe1cf4c3e513e92191a60a2

Fixes #1789 - Parent hostgroup name is truncated when its sub-group is a sub-string of the parent hostgroup name

View differences:

app/helpers/hosts_and_hostgroups_helper.rb
def hostgroup_name group, max_length = 1000
return if group.blank?
options = (group.to_s.size > max_length) ? {:'data-original-title'=> group.to_s, :rel=>'twipsy'} : {}
nesting = group.to_s.gsub(group.name, "")
nesting = group.to_s.gsub(/[^\/]+\/?$/, "")
nesting = truncate(nesting, :length => max_length - group.name.size) if nesting.size > 0
name = truncate(group.name.to_s, :length => max_length - nesting.size)
link_to_if_authorized(
test/unit/helpers/host_groups_helper_test.rb
require 'test_helper'
class HostGroupsHelperTest < ActionView::TestCase
include ActionView::Helpers::TagHelper
include HostsAndHostgroupsHelper
include ApplicationHelper
test "should have the full string of the parent class if the child is a substring" do
test_group = Hostgroup.create(:name => "test/st")
assert hostgroup_name(test_group).include?("test/st")
assert !hostgroup_name(test_group).include?("te/st")
end
end

Also available in: Unified diff