swi-prolog: update to 9.2.9
[oi-userland.git] / components / ruby / puppet / patches / puppet-17-user-comment-with-ruby-2.1.patch
blobcf6ac043a6ee3fae770cfe022cdbd4abece83ecb
1 From: =?utf-8?q?C=C3=A9dric_Barboiron?= <ced@winkie.fr>
2 Date: Thu, 28 May 2015 14:30:05 +0200
3 Subject: (PUP-4633) fix non-ASCII user comment with ruby >= 2.1
5 Conflicts:
6 spec/unit/type/user_spec.rb
7 ---
8 lib/puppet/type/user.rb | 6 ++++--
9 spec/unit/type/user_spec.rb | 21 ++++++++++++++-------
10 2 files changed, 18 insertions(+), 9 deletions(-)
12 diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb
13 index 81ad39a..0df5978 100644
14 --- a/lib/puppet/type/user.rb
15 +++ b/lib/puppet/type/user.rb
16 @@ -167,8 +167,10 @@ module Puppet
18 newproperty(:comment) do
19 desc "A description of the user. Generally the user's full name."
20 - munge do |v|
21 - v.respond_to?(:force_encoding) ? v.force_encoding(Encoding::ASCII_8BIT) : v
22 + if RUBY_VERSION < "2.1.0"
23 + munge do |v|
24 + v.respond_to?(:force_encoding) ? v.force_encoding(Encoding::ASCII_8BIT) : v
25 + end
26 end
27 end
29 diff --git a/spec/unit/type/user_spec.rb b/spec/unit/type/user_spec.rb
30 index 9740543..933e5fa 100755
31 --- a/spec/unit/type/user_spec.rb
32 +++ b/spec/unit/type/user_spec.rb
33 @@ -344,13 +344,20 @@ describe Puppet::Type.type(:user) do
34 end
35 end
37 - describe "when managing comment on Ruby 1.9", :if => String.method_defined?(:encode) do
38 - it "should force value encoding to ASCII-8BIT" do
39 - value = 'abcd™'
40 - value.encoding.should == Encoding::UTF_8
41 - user = described_class.new(:name => 'foo', :comment => value)
42 - user[:comment].encoding.should == Encoding::ASCII_8BIT
43 - user[:comment].should == value.force_encoding(Encoding::ASCII_8BIT)
44 + describe "when managing comment" do
45 + before :each do
46 + @value = 'abcd™'
47 + expect(@value.encoding).to eq(Encoding::UTF_8)
48 + @user = described_class.new(:name => 'foo', :comment => @value)
49 + end
51 + it "should be converted to ASCII_8BIT for ruby 1.9 / 2.0", :if => RUBY_VERSION < "2.1.0" && String.method_defined?(:encode) do
52 + expect(@user[:comment].encoding).to eq(Encoding::ASCII_8BIT)
53 + expect(@user[:comment]).to eq(@value.force_encoding(Encoding::ASCII_8BIT))
54 + end
56 + it "must not be converted for ruby >= 2.1", :if => RUBY_VERSION >= "2.1.0" do
57 + expect(@user[:comment].encoding).to eq(Encoding::UTF_8)
58 end
59 end