summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjtimberman <joshua@opscode.com>2014-01-07 09:37:16 -0700
committerjtimberman <joshua@opscode.com>2014-01-07 09:37:16 -0700
commit42e97ee5282a52c28fb72c53722f8afbcbc33bdb (patch)
treeaaedc5839f3afa74a55507b55f5ca03d6518c52a
parent6919643a4b825fe70014f0e30fa73d649227daf6 (diff)
downloadchef-42e97ee5282a52c28fb72c53722f8afbcbc33bdb.tar.gz
CHEF-4927 - coerce group GID to string
To remain consistent with the way the user provider works, coerce both new_resource and current_resource GIDs to strings for comparison. This allows users to write their resources like: group "zone" do gid 233 end or group "zone" do gid "233" end Without this change, every time Chef runs when a string GID is specified, it will modify the group, which is not desirable.
-rw-r--r--lib/chef/provider/group.rb2
-rw-r--r--spec/unit/provider/group_spec.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/chef/provider/group.rb b/lib/chef/provider/group.rb
index 09c2a0052d..c091116c08 100644
--- a/lib/chef/provider/group.rb
+++ b/lib/chef/provider/group.rb
@@ -84,7 +84,7 @@ class Chef
# <false>:: If a change is not required
def compare_group
@change_desc = [ ]
- if @new_resource.gid != @current_resource.gid
+ if @new_resource.gid.to_s != @current_resource.gid.to_s
@change_desc << "change gid #{@current_resource.gid} to #{@new_resource.gid}"
end
diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb
index a076593511..010e5ad006 100644
--- a/spec/unit/provider/group_spec.rb
+++ b/spec/unit/provider/group_spec.rb
@@ -96,6 +96,11 @@ describe Chef::Provider::User do
@provider.compare_group.should be_false
end
+ it "should coerce an integer to a string for comparison" do
+ @current_resource.stub!(:gid).and_return("500")
+ @provider.compare_group.should be_false
+ end
+
it "should return false if append is true and the group member(s) already exists" do
@current_resource.members << "extra_user"
@new_resource.stub!(:append).and_return(true)