diff options
| author | Jesse Wolfe <jes5199@gmail.com> | 2010-04-26 18:14:51 -0700 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | f66095d35bc5f9645eb19bbb8cefa342c0181d2d (patch) | |
| tree | 8ee659a9a78c81bea4ad0914403b0d924506f3dd /spec/unit | |
| parent | f0a00848d9244f03528f6cd9572989732e4b6fe2 (diff) | |
| download | puppet-f66095d35bc5f9645eb19bbb8cefa342c0181d2d.tar.gz puppet-f66095d35bc5f9645eb19bbb8cefa342c0181d2d.tar.xz puppet-f66095d35bc5f9645eb19bbb8cefa342c0181d2d.zip | |
Fix #3656 JSON serialization of dependencies
The pson serialization of resources was behaving incorrectly on
parameters that are references to other resources:
1. Dependency parameters (require, subscribe, notify) were getting
serialized as anonymous objects that looked like partially constructed
resources
2. During de-serialization the pson parser would inflate them
into hashes (rather than into resources)
3. The outer resource would try to coerce the hash into a resource by
passing it to Resource.new
4. Resource.new would fail with a cryptic message, since it does not
accept a hash as its first parameter (but the error is obfuscated by
Resource.new's complicated argument handler)
This patch solves the problem by explicitly converting dependency
parameters into strings in the pson serialization.
Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/resource.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/spec/unit/resource.rb b/spec/unit/resource.rb index 0eacd0b90..3840db535 100755 --- a/spec/unit/resource.rb +++ b/spec/unit/resource.rb @@ -664,6 +664,13 @@ describe Puppet::Resource do result["foo"].should == %w{bar eh} result["fee"].should == %w{baz} end + + it "should serialize relationships as reference strings" do + resource = Puppet::Resource.new("File", "/foo") + resource[:requires] = Puppet::Resource.new("File", "/bar") + result = Puppet::Resource.from_pson(PSON.parse(resource.to_pson)) + result[:requires].should == "File[/bar]" + end end describe "when converting from pson" do |
