summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2012-09-06 16:05:27 -0700
committerdanielsdeleo <dan@opscode.com>2012-09-06 16:05:27 -0700
commit3ad999dcdd075104090f60cf158f0d25a54e80da (patch)
tree2dd4680f46c713bfae08abb97f952b9ae615853d
parent599f156279d6a2f7a301126e0c56b65e4547b39c (diff)
downloadchef-OC-3395-link.tar.gz
add state attrs for link resourceOC-3395-link
-rw-r--r--chef/lib/chef/resource/link.rb11
-rw-r--r--chef/spec/unit/resource/link_spec.rb8
2 files changed, 19 insertions, 0 deletions
diff --git a/chef/lib/chef/resource/link.rb b/chef/lib/chef/resource/link.rb
index a0c5726abc..33a30f428f 100644
--- a/chef/lib/chef/resource/link.rb
+++ b/chef/lib/chef/resource/link.rb
@@ -26,6 +26,17 @@ class Chef
provides :link, :on_platform => :all
+ identity_attr :target_file
+
+ state_attrs :link_type, :to
+
+ state_attrs :owner, :group, :mode
+
+ # By default, windows gets `state_attrs :rights, :deny_rights`
+ if Platform.windows?
+ state_attrs :rights, :deny_rights
+ end
+
def initialize(name, run_context=nil)
super
@resource_name = :link
diff --git a/chef/spec/unit/resource/link_spec.rb b/chef/spec/unit/resource/link_spec.rb
index b519303f9f..0a79506ebd 100644
--- a/chef/spec/unit/resource/link_spec.rb
+++ b/chef/spec/unit/resource/link_spec.rb
@@ -51,6 +51,14 @@ describe Chef::Resource::Link do
@resource.target_file.should eql("fakey_fakerton")
end
+ it "uses the target_file as the identity attribute" do
+ @resource.identity.should == "fakey_fakerton"
+ end
+
+ it "has state attributes :link_type, :to, and permissions attributes" do
+ @resource.state.keys.should =~ [:owner, :mode, :group, :link_type, :to]
+ end
+
it "should accept a string as the link source via 'to'" do
lambda { @resource.to "/tmp" }.should_not raise_error(ArgumentError)
end