Revision 9158ff3c
Added by Dominic Cleal almost 10 years ago
app/models/lookup_value.rb | ||
---|---|---|
attr_accessor :host_or_hostgroup
|
||
|
||
serialize :value
|
||
attr_name :value
|
||
attr_name :match
|
||
|
||
scope :default, lambda { where(:match => "default").limit(1) }
|
||
|
||
... | ... | |
scoped_search :in => :lookup_key, :on => :key, :rename => :lookup_key, :complete_value => true
|
||
|
||
def name
|
||
value
|
||
match
|
||
end
|
||
|
||
def value_before_type_cast
|
test/unit/hostgroup_test.rb | ||
---|---|---|
end
|
||
|
||
test "should find associated lookup_values" do
|
||
assert_equal [lookup_values(:hostgroupcommon), lookup_values(:four)], hostgroups(:common).lookup_values.sort
|
||
assert_equal [lookup_values(:hostgroupcommon), lookup_values(:four)].map(&:id).sort, hostgroups(:common).lookup_values.map(&:id).sort
|
||
end
|
||
|
||
test "should find associated lookup_values with unsafe SQL name" do
|
||
... | ... | |
lv = lookup_values(:four)
|
||
lv.match = "hostgroup=#{hostgroup.name}"
|
||
lv.save!
|
||
assert_equal [lookup_values(:hostgroupcommon), lookup_values(:four)], hostgroup.lookup_values.sort
|
||
assert_equal [lookup_values(:hostgroupcommon), lookup_values(:four)].map(&:id).sort, hostgroup.lookup_values.map(&:id).sort
|
||
end
|
||
|
||
# test NestedAncestryCommon methods generate by class method nested_attribute_for
|
Also available in: Unified diff
fixes #5671 - LookupValue name should be matcher, value is too long