Project

General

Profile

« Previous | Next » 

Revision 8fd3c579

Added by Dominic Cleal over 8 years ago

fixes #11807 - update existing lookup value when changed from nested host form

View differences:

test/unit/host_test.rb
end
end
test "lookup_values_attributes= updates existing lookup values" do
host = FactoryGirl.create(:host, :with_puppetclass)
lkey = FactoryGirl.create(:puppetclass_lookup_key, :as_smart_class_param, :puppetclass => host.classes.first, :overrides => {"fqdn=#{host.name}" => 'old value'})
lval = host.lookup_values.first
host.lookup_values_attributes = {'0' => {'lookup_key_id' => lkey.id.to_s, 'value' => 'new value', '_destroy' => 'false', 'id' => lval.id.to_s}}.with_indifferent_access
assert_equal 'old value', LookupValue.find(lval.id).value
host.save!
assert_equal 'new value', LookupValue.find(lval.id).value
end
test "same works for destruction of lookup keys" do
host = FactoryGirl.create(:host, :lookup_values_attributes => {"new_123456" => {"lookup_key_id" => lookup_keys(:complex).id, "value"=>"some_value", "match" => "fqdn=abc.mydomain.net"}})
lookup_value = host.lookup_values.first

Also available in: Unified diff