Project

General

Profile

« Previous | Next » 

Revision 7cd51106

Added by Tom Caspy over 8 years ago

fixes #11570 - returning 'dependent destroy' to lookup values

View differences:

app/models/concerns/host_common.rb
alias_method :all_puppetclasses, :classes
has_many :lookup_values, :primary_key => :lookup_value_matcher, :foreign_key => :match, :validate => false
has_many :lookup_values, :primary_key => :lookup_value_matcher, :foreign_key => :match, :validate => false, :dependent => :destroy
# See "def lookup_values_attributes=" under, for the implementation of accepts_nested_attributes_for :lookup_values
accepts_nested_attributes_for :lookup_values
test/unit/host_test.rb
assert_equal "fqdn=#{host.shortname}.yourdomain.net", LookupValue.find(lookup_value.id).match
end
test "destroying host should destroy lookup values" do
host = FactoryGirl.create(:host)
lookup_key = FactoryGirl.create(:lookup_key, :is_param)
lookup_value = FactoryGirl.create(:lookup_value, :lookup_key_id => lookup_key.id,
:match => "fqdn=#{host.fqdn}", :value => '8080')
host.reload
host.destroy
assert LookupValue.where(:id => lookup_value.id).first.blank?
end
test '#setup_clone skips new records' do
assert_nil FactoryGirl.build(:host, :managed).send(:setup_clone)
end

Also available in: Unified diff