diff options
-rw-r--r-- | lib/chef/provider/file.rb | 3 | ||||
-rw-r--r-- | spec/unit/provider/file_spec.rb | 26 |
2 files changed, 27 insertions, 2 deletions
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb index e59fd8bb7d..c0805674ec 100644 --- a/lib/chef/provider/file.rb +++ b/lib/chef/provider/file.rb @@ -32,6 +32,7 @@ class Chef @current_resource.owner(cstats.uid) @current_resource.group(cstats.gid) @current_resource.mode("%o" % (cstats.mode & 007777)) + checksum end @current_resource end @@ -72,7 +73,7 @@ class Chef @set_group_id = @new_resource.group.to_i @set_group_id == @current_resource.group else - group_info = Etc.getpwnam(@new_resource.group) + group_info = Etc.getgrnam(@new_resource.group) @set_group_id = group_info.gid @set_group_id == @current_resource.group end diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb index b31a4d7ef1..2ee6b1960e 100644 --- a/spec/unit/provider/file_spec.rb +++ b/spec/unit/provider/file_spec.rb @@ -127,6 +127,30 @@ describe Chef::Provider::File do end end + it "should compare the current group with the requested group" do + @provider.load_current_resource + @provider.new_resource.stub!(:group).and_return("adam") + Etc.stub!(:getgrnam).and_return( + OpenStruct.new( + :name => "adam", + :gid => 501 + ) + ) + @provider.current_resource.group(501) + @provider.compare_group.should eql(true) + + @provider.current_resource.group(777) + @provider.compare_group.should eql(false) + + @provider.new_resource.stub!(:group).and_return(501) + @provider.current_resource.group(501) + @provider.compare_group.should eql(true) + + @provider.new_resource.stub!(:group).and_return("501") + @provider.current_resource.group(501) + @provider.compare_group.should eql(true) + end + it "should set the group on the file to the requested group" do @provider.load_current_resource @provider.new_resource.stub!(:group).and_return(9982398) @@ -135,7 +159,7 @@ describe Chef::Provider::File do lambda { @provider.set_group }.should_not raise_error end - it "should raise an exception if you are not root and try to change ownership" do + it "should raise an exception if you are not root and try to change the group" do @provider.load_current_resource @provider.new_resource.stub!(:group).and_return(0) if Process.uid != 0 |