summaryrefslogtreecommitdiffstats
path: root/test/rails/railsresource.rb
diff options
context:
space:
mode:
authorshadoi <shadoi@980ebf18-57e1-0310-9a29-db15c13687c0>2006-11-09 18:57:01 +0000
committershadoi <shadoi@980ebf18-57e1-0310-9a29-db15c13687c0>2006-11-09 18:57:01 +0000
commitcf166c25911f521cdf12178ebbe0b39f81473b35 (patch)
tree1a96094de1203cb3d48b6c07255414bea351092a /test/rails/railsresource.rb
parent28c283c73388c3f76e1d715c41ebd82ac35ca9a4 (diff)
downloadpuppet-cf166c25911f521cdf12178ebbe0b39f81473b35.tar.gz
puppet-cf166c25911f521cdf12178ebbe0b39f81473b35.tar.xz
puppet-cf166c25911f521cdf12178ebbe0b39f81473b35.zip
Rails stuff part 1
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1837 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/rails/railsresource.rb')
-rwxr-xr-xtest/rails/railsresource.rb27
1 files changed, 16 insertions, 11 deletions
diff --git a/test/rails/railsresource.rb b/test/rails/railsresource.rb
index 666d26bcf..e109ba7d1 100755
--- a/test/rails/railsresource.rb
+++ b/test/rails/railsresource.rb
@@ -22,33 +22,38 @@ class TestRailsResource < Test::Unit::TestCase
host = Puppet::Rails::Host.new(:name => "myhost")
# Now build a resource
- resource = host.rails_resources.build(
- :title => "/tmp/to_resource", :restype => "file",
- :exported => true
- )
-
+ resource = host.resources.create(
+ :title => "/tmp/to_resource",
+ :exported => true)
+
+ # For some reason the child class doesn't exist until after the resource is created.
+ # Probably an issue with the dynamic class generation.
+ resource.type = "PuppetFile"
+ resource.save
+
# Now add some params
{"owner" => "root", "mode" => "644"}.each do |param, value|
- resource.rails_parameters.build(
- :name => param, :value => value
- )
+ pn = resource.param_names.find_or_create_by_name(param)
+ pv = pn.param_values.find_or_create_by_value(value)
+ resource.param_names << pn
end
# Now save the whole thing
host.save
- # Now, try to convert our resource to a real resource
# We need a scope
interp, scope, source = mkclassframing
+ # Find the new resource and include all it's parameters.
+ resource = Puppet::Rails::Resource.find_by_id(resource.id, :include => [ :param_names, :param_values ])
+
+ # Now, try to convert our resource to a real resource
res = nil
assert_nothing_raised do
res = resource.to_resource(scope)
end
-
assert_instance_of(Puppet::Parser::Resource, res)
-
assert_equal("root", res[:owner])
assert_equal("644", res[:mode])
assert_equal("/tmp/to_resource", res.title)