summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-12-10 12:16:08 -0600
committerLuke Kanies <luke@madstop.com>2007-12-10 12:16:08 -0600
commitae33e57d1bb94827f488374a7dba8a96fa8e541f (patch)
tree471a42b819a3c64978497d04580ef14b5ccbc76e
parent9ad7d1a7255a89383bc2b8c6b72c79bc050945a3 (diff)
downloadpuppet-ae33e57d1bb94827f488374a7dba8a96fa8e541f.tar.gz
puppet-ae33e57d1bb94827f488374a7dba8a96fa8e541f.tar.xz
puppet-ae33e57d1bb94827f488374a7dba8a96fa8e541f.zip
Fixing #923 (again). The host storage method was not
correctly searching for the host, so it was creating a new host on each run, which is what was causing the conflict.
-rw-r--r--lib/puppet/rails/host.rb4
-rwxr-xr-xtest/rails/host.rb9
2 files changed, 6 insertions, 7 deletions
diff --git a/lib/puppet/rails/host.rb b/lib/puppet/rails/host.rb
index 9ecacdd6f..72898fd97 100644
--- a/lib/puppet/rails/host.rb
+++ b/lib/puppet/rails/host.rb
@@ -29,15 +29,13 @@ class Puppet::Rails::Host < ActiveRecord::Base
# Store our host in the database.
def self.store(node, resources)
- raise ArgumentError, "You must specify the hostname for storage" unless name = hash[:name]
-
args = {}
host = nil
transaction do
#unless host = find_by_name(name)
seconds = Benchmark.realtime {
- unless host = find_by_name(name)
+ unless host = find_by_name(node.name)
host = new(:name => node.name)
end
}
diff --git a/test/rails/host.rb b/test/rails/host.rb
index 5853e8219..582bebcb2 100755
--- a/test/rails/host.rb
+++ b/test/rails/host.rb
@@ -51,8 +51,7 @@ class TestRailsHost < PuppetTest::TestCase
}
# Now collect our facts
- facts = {"hostname" => Facter.value(:hostname), "test1" => "funtest",
- "ipaddress" => Facter.value(:ipaddress)}
+ facts = {"hostname" => "myhost", "test1" => "funtest", "ipaddress" => "192.168.0.1"}
# Now try storing our crap
host = nil
@@ -120,13 +119,15 @@ class TestRailsHost < PuppetTest::TestCase
facts["test3"] = "funtest"
facts["test1"] = "changedfact"
facts.delete("ipaddress")
- host = nil
node = mknode(facts["hostname"])
node.parameters = facts
+ newhost = nil
assert_nothing_raised {
- host = Puppet::Rails::Host.store(node, resources)
+ newhost = Puppet::Rails::Host.store(node, resources)
}
+ assert_equal(host.id, newhost.id, "Created new host instance)")
+
# Make sure it sets the last_compile time
assert_nothing_raised do
assert_instance_of(Time, host.last_compile, "did not set last_compile")