summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2010-06-30 09:34:29 -0700
committerDaniel DeLeo <dan@opscode.com>2010-06-30 09:34:29 -0700
commit6ce67aff8ffda2b54706779f4cd771e30066c24b (patch)
tree4374c7304922c0bb2e9ef05f23fd02349a391de7
parentaf950d200b0c8672897b9ac71701208658127fa0 (diff)
parent01a39099b5f78ac9d84659dbec55911405fa53ba (diff)
downloadchef-6ce67aff8ffda2b54706779f4cd771e30066c24b.tar.gz
Merge branch 'CHEF-1021'
-rw-r--r--chef/lib/chef/provider/deploy.rb5
-rw-r--r--chef/spec/unit/provider/deploy_spec.rb32
2 files changed, 35 insertions, 2 deletions
diff --git a/chef/lib/chef/provider/deploy.rb b/chef/lib/chef/provider/deploy.rb
index 52264255e7..23dd0998ce 100644
--- a/chef/lib/chef/provider/deploy.rb
+++ b/chef/lib/chef/provider/deploy.rb
@@ -51,7 +51,10 @@ class Chef
def run(command, &block)
exec = execute(command, &block)
- exec.user(@new_resource.user)
+ exec.user(@new_resource.user) if @new_resource.user
+ exec.group(@new_resource.group) if @new_resource.group
+ exec.cwd(release_path) unless exec.cwd
+ exec.environment(@new_resource.environment) unless exec.environment
exec
end
diff --git a/chef/spec/unit/provider/deploy_spec.rb b/chef/spec/unit/provider/deploy_spec.rb
index a08f596b86..d6e1c1211d 100644
--- a/chef/spec/unit/provider/deploy_spec.rb
+++ b/chef/spec/unit/provider/deploy_spec.rb
@@ -381,11 +381,41 @@ describe Chef::Provider::Deploy do
@provider.sudo("the moon, fool")
end
- it "defines run as a forwarder to execute, setting the user to new_resource.user" do
+ it "defines run as a forwarder to execute, setting the user, group, cwd and environment to new_resource.user" do
mock_execution = mock("Resource::Execute")
@provider.should_receive(:execute).with("iGoToHell4this").and_return(mock_execution)
@resource.user("notCoolMan")
+ @resource.group("Ggroup")
+ @resource.environment("APP_ENV" => 'staging')
+ @resource.deploy_to("/my/app")
mock_execution.should_receive(:user).with("notCoolMan")
+ mock_execution.should_receive(:group).with("Ggroup")
+ mock_execution.should_receive(:cwd){|*args|
+ if args.empty?
+ nil
+ else
+ args.size.should == 1
+ args.first.should == @provider.release_path
+ end
+ }.twice
+ mock_execution.should_receive(:environment){ |*args|
+ if args.empty?
+ nil
+ else
+ args.size.should == 1
+ args.first.should == {"APP_ENV" => "staging"}
+ end
+ }.twice
+ @provider.run("iGoToHell4this")
+ end
+
+ it "defines run as a forwarder to execute, setting cwd and environment but not override" do
+ mock_execution = mock("Resource::Execute")
+ @provider.should_receive(:execute).with("iGoToHell4this").and_return(mock_execution)
+ @resource.user("notCoolMan")
+ mock_execution.should_receive(:user).with("notCoolMan")
+ mock_execution.should_receive(:cwd).with(no_args()).and_return("/some/value")
+ mock_execution.should_receive(:environment).with(no_args()).and_return({})
@provider.run("iGoToHell4this")
end