Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
puppet.14603
puppet-3.8.5-non_ASCII_user_comment.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File puppet-3.8.5-non_ASCII_user_comment.patch of Package puppet.14603
From 302369f4c335ffb87983506dcac6679de22878cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Barboiron?= <ced@winkie.fr> Date: Thu, 28 May 2015 14:30:05 +0200 Subject: [PATCH] (PUP-4633) fix non-ASCII user comment with ruby >= 2.1 --- lib/puppet/type/user.rb | 6 ++++-- spec/unit/type/user_spec.rb | 21 ++++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) Index: puppet-3.8.5/lib/puppet/type/user.rb =================================================================== --- puppet-3.8.5.orig/lib/puppet/type/user.rb +++ puppet-3.8.5/lib/puppet/type/user.rb @@ -167,8 +167,10 @@ module Puppet newproperty(:comment) do desc "A description of the user. Generally the user's full name." - munge do |v| - v.respond_to?(:force_encoding) ? v.force_encoding(Encoding::ASCII_8BIT) : v + if RUBY_VERSION < "2.1.0" + munge do |v| + v.respond_to?(:force_encoding) ? v.force_encoding(Encoding::ASCII_8BIT) : v + end end end Index: puppet-3.8.5/spec/unit/type/user_spec.rb =================================================================== --- puppet-3.8.5.orig/spec/unit/type/user_spec.rb +++ puppet-3.8.5/spec/unit/type/user_spec.rb @@ -344,13 +344,20 @@ describe Puppet::Type.type(:user) do end end - describe "when managing comment on Ruby 1.9", :if => String.method_defined?(:encode) do - it "should force value encoding to ASCII-8BIT" do - value = 'abcd™' - value.encoding.should == Encoding::UTF_8 - user = described_class.new(:name => 'foo', :comment => value) - user[:comment].encoding.should == Encoding::ASCII_8BIT - user[:comment].should == value.force_encoding(Encoding::ASCII_8BIT) + describe "when managing comment" do + before :each do + @value = 'abcd™' + expect(@value.encoding).to eq(Encoding::UTF_8) + @user = described_class.new(:name => 'foo', :comment => @value) + end + + it "should be converted to ASCII_8BIT for ruby 1.9 / 2.0", :if => RUBY_VERSION < "2.1.0" && String.method_defined?(:encode) do + expect(@user[:comment].encoding).to eq(Encoding::ASCII_8BIT) + expect(@user[:comment]).to eq(@value.force_encoding(Encoding::ASCII_8BIT)) + end + + it "must not be converted for ruby >= 2.1", :if => RUBY_VERSION >= "2.1.0" do + expect(@user[:comment].encoding).to eq(Encoding::UTF_8) end end
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor