Permalink
Browse files

Ensure that the default run options are mixed into the command option…

…s when executing a command from the cap shell (closes #11348)

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@9025 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 9e07fd2 commit 526782f55d16e2d05515632eb2a106d79a73c284 @jamis jamis committed Mar 14, 2008
Showing with 30 additions and 1 deletion.
  1. +2 −0 CHANGELOG
  2. +2 −1 lib/capistrano/shell.rb
  3. +26 −0 test/shell_test.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Ensure that the default run options are mixed into the command options when executing a command from the cap shell [Ken Collins]
+
* Added :none SCM module for deploying a specific directory's contents [Jamis Buck]
* Improved "copy" strategy supports local caching and pattern exclusion (via :copy_cache and :copy_exclude variables) [Jamis Buck]
View
@@ -169,7 +169,8 @@ def exec_command(command, servers)
command = command.gsub(/\bsudo\b/, "sudo -p '#{configuration.sudo_prompt}'")
processor = configuration.sudo_behavior_callback(Configuration.default_io_proc)
sessions = servers.map { |server| configuration.sessions[server] }
- cmd = Command.new(command, sessions, :logger => configuration.logger, &processor)
+ options = configuration.add_default_command_options({})
+ cmd = Command.new(command, sessions, options.merge(:logger => configuration.logger), &processor)
previous = trap("INT") { cmd.stop! }
cmd.process!
rescue Capistrano::Error => error
View
@@ -61,4 +61,30 @@ def test_text_with_on_gets_processed_with_on
@shell.expects(:process_command).with("on", "app,db", "hello world")
assert @shell.read_and_execute
end
+
+ def test_task_command_with_bang_gets_processed_by_exec_tasks
+ while_testing_post_exec_commands do
+ @shell.expects(:read_line).returns("!deploy")
+ @shell.expects(:exec_tasks).with(["deploy"])
+ assert @shell.read_and_execute
+ end
+ end
+
+ def test_normal_command_gets_processed_by_exec_command
+ while_testing_post_exec_commands do
+ @shell.expects(:read_line).returns("uptime")
+ @shell.expects(:exec_command).with("uptime",nil)
+ @shell.expects(:connect)
+ assert @shell.read_and_execute
+ end
+ end
+
+
+ private
+
+ def while_testing_post_exec_commands(&block)
+ @shell.instance_variable_set(:@mutex,Mutex.new)
+ yield
+ end
+
end

0 comments on commit 526782f

Please sign in to comment.