Commit ec0a2734 authored by Serdar Sutay's avatar Serdar Sutay
Browse files

Merge pull request #1299 from opscode/contributions-cc-51

CC-51: Merging Chef Contributions.
parents ce7593ee 19248f12
......@@ -19,6 +19,10 @@
* Upgrade ohai to 7.0.0.rc.0
* Make the initial bootstrap message more user friendly (CHEF-5102)
* Correctly handle exceptions in formatters when exception.message is nil (CHEF-4743)
* Fix convergence message in deploy provider (CHEF-4929)
* Make group resource idempotent when gid is specified as a string. (CHEF-4927)
* Non-dupable elements are now handled when duping attribute arrays. (CHEF-4799)
* ruby-shadow is not installed on cygwin platform anymore. (CHEF-4946)
## Last Release: 11.10.0 (02/06/2014)
......
......@@ -9,3 +9,6 @@ Example Contribution:
* **jonlives**: Changed the order of recipe and cookbook name setting. Fixes CHEF-5052.
* **jaymzh**: Added support for `enable` and `disable` to MacOSX service provider.
* **bossmc**: Made formatters more resilient to nil exception messages.
* **valodzka**: Fixed the convergence message in deploy provider.
* **linkfanel**: Made attribute arrays able to handle non-dupable elements while being duped.
* **linkfanel**: Removed ruby-shadow installation on cygwin platform.
......@@ -11,7 +11,7 @@ group(:development, :test) do
gem "simplecov"
gem 'rack', "~> 1.5.1"
gem 'ruby-shadow', :platforms => :ruby unless RUBY_PLATFORM.downcase.match(/aix/)
gem 'ruby-shadow', :platforms => :ruby unless RUBY_PLATFORM.downcase.match(/(aix|cygwin)/)
end
# If you want to load debugging tools into the bundle exec sandbox,
......
......@@ -76,8 +76,15 @@ class Chef
super(data)
end
# For elements like Fixnums, true, nil...
def safe_dup(e)
e.dup
rescue TypeError
e
end
def dup
Array.new(map {|e| e.dup})
Array.new(map {|e| safe_dup(e)})
end
end
......
......@@ -85,8 +85,15 @@ class Chef
METHOD_DEFN
end
# For elements like Fixnums, true, nil...
def safe_dup(e)
e.dup
rescue TypeError
e
end
def dup
Array.new(map {|e| e.dup })
Array.new(map {|e| safe_dup(e)})
end
end
......
......@@ -266,7 +266,7 @@ class Chef
def copy_cached_repo
target_dir_path = @new_resource.deploy_to + "/releases"
converge_by("deploy from repo to #{@target_dir_path} ") do
converge_by("deploy from repo to #{target_dir_path} ") do
FileUtils.rm_rf(release_path) if ::File.exist?(release_path)
FileUtils.mkdir_p(target_dir_path)
FileUtils.cp_r(::File.join(@new_resource.destination, "."), release_path, :preserve => true)
......
......@@ -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
......
......@@ -488,6 +488,13 @@ describe Chef::Node::Attribute do
end
end
describe "dup" do
it "array can be duped even if some elements can't" do
@attributes.default[:foo] = %w[foo bar baz] + Array(1..3) + [nil, true, false, [ "el", 0, nil ] ]
@attributes.default[:foo].dup
end
end
describe "has_key?" do
it "should return true if an attribute exists" do
@attributes.has_key?("music").should == true
......
......@@ -86,7 +86,7 @@ end
describe Chef::Node::ImmutableArray do
before do
@immutable_array = Chef::Node::ImmutableArray.new(%w[foo bar baz])
@immutable_array = Chef::Node::ImmutableArray.new(%w[foo bar baz] + Array(1..3) + [nil, true, false, [ "el", 0, nil ] ])
end
##
......@@ -130,6 +130,10 @@ describe Chef::Node::ImmutableArray do
end
end
it "can be duped even if some elements can't" do
@immutable_array.dup
end
it "returns a mutable version of itself when duped" do
mutable = @immutable_array.dup
mutable[0] = :value
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment