diff options
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/windows.rb | 10 | ||||
-rw-r--r-- | lib/chef/resource/user.rb | 6 | ||||
-rw-r--r-- | spec/unit/resource/user_spec.rb | 4 |
3 files changed, 15 insertions, 5 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb b/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb index 46176901dd..c6cd597fe0 100644 --- a/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb +++ b/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb @@ -125,4 +125,12 @@ include_recipe "::_ohai_hint" hostname "new-hostname" do windows_reboot false -end
\ No newline at end of file +end + +user "phil" do + uid "8019" +end + +user "phil" do + action :remove +end diff --git a/lib/chef/resource/user.rb b/lib/chef/resource/user.rb index 408932175d..d0ff0e3eae 100644 --- a/lib/chef/resource/user.rb +++ b/lib/chef/resource/user.rb @@ -67,10 +67,12 @@ class Chef default: false property :uid, [ String, Integer, NilClass ], # nil for backwards compat - description: "The numeric user identifier." + description: "The numeric user identifier.", + coerce: proc { |n| n && Integer(n) } property :gid, [ String, Integer, NilClass ], # nil for backwards compat - description: "The numeric group identifier." + description: "The numeric group identifier.", + coerce: proc { |n| n && Integer(n) } alias_method :group, :gid end diff --git a/spec/unit/resource/user_spec.rb b/spec/unit/resource/user_spec.rb index 58c17024af..5f8c189502 100644 --- a/spec/unit/resource/user_spec.rb +++ b/spec/unit/resource/user_spec.rb @@ -85,7 +85,7 @@ end it "allows a string" do resource.send(attrib, "100") - expect(resource.send(attrib)).to eql("100") + expect(resource.send(attrib)).to eql(100) end it "allows an integer" do @@ -94,7 +94,7 @@ end end it "does not allow a hash" do - expect { resource.send(attrib, { woot: "i found it" }) }.to raise_error(ArgumentError) + expect { resource.send(attrib, { woot: "i found it" }) }.to raise_error(TypeError) end end |