diff options
author | Tobias Schmidt <ts@soundcloud.com> | 2013-12-03 12:49:56 +0700 |
---|---|---|
committer | Tobias Schmidt <ts@soundcloud.com> | 2013-12-04 01:41:34 +0700 |
commit | bff171e7a00f951231efdb45e51c0ae1d97ba05d (patch) | |
tree | bbb49f706fc9cf66d2e16831005413042d139f2c /spec/unit | |
parent | 41ca23434f820885dd6d78ca49403b24d7400949 (diff) | |
download | chef-bff171e7a00f951231efdb45e51c0ae1d97ba05d.tar.gz |
[CHEF-4842] Fix comparison of user resources with non-ASCII comments
In case a comment of a user resource includes non-ASCII characters, the
comparison whether the resource was changed will always fail. Therefore,
such user resources will get modified during every chef-client run.
Example:
user "marci" do
comment "Márton Salomváry"
# ...
end
So far, this resulted in a comparision of "M\xC3\xA1rton
Salomv\xC3\xA1ry" with "Márton Salomváry" which fails, unless the
encoding gets changed prior to the comparision.
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/provider/user_spec.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/spec/unit/provider/user_spec.rb b/spec/unit/provider/user_spec.rb index d054fcc440..d5e694b79c 100644 --- a/spec/unit/provider/user_spec.rb +++ b/spec/unit/provider/user_spec.rb @@ -91,6 +91,12 @@ describe Chef::Provider::User do @current_resource.username.should == @new_resource.username end + it "should change the encoding of gecos to the encoding of the new resource", :ruby_gte_19_only do + @pw_user.gecos.force_encoding('ASCII-8BIT') + @provider.load_current_resource + @provider.current_resource.comment.encoding.should == @new_resource.comment.encoding + end + it "should look up the user in /etc/passwd with getpwnam" do Etc.should_receive(:getpwnam).with(@new_resource.username).and_return(@pw_user) @provider.load_current_resource |