Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
Added support for --dry-run option to deploy task.(cherry picked from…
Browse files Browse the repository at this point in the history
… commit 40be1db715204684ffbc30d46531199b8b778698)
  • Loading branch information
Alessandro Morandi authored and Jon Yurek committed Mar 30, 2011
1 parent ea8535a commit 496f12b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/hoptoad_notifier/capistrano.rb
Expand Up @@ -11,6 +11,7 @@
local_user = ENV['USER'] || ENV['USERNAME']
executable = RUBY_PLATFORM.downcase.include?('mswin') ? 'rake.bat' : 'rake'
notify_command = "#{executable} hoptoad:deploy TO=#{rails_env} REVISION=#{current_revision} REPO=#{repository} USER=#{local_user}"
notify_command << " DRY_RUN=true" if dry_run
notify_command << " API_KEY=#{ENV['API_KEY']}" if ENV['API_KEY']
puts "Notifying Hoptoad of Deploy (#{notify_command})"
`#{notify_command}`
Expand Down
3 changes: 2 additions & 1 deletion lib/hoptoad_notifier/shared_tasks.rb
Expand Up @@ -6,7 +6,8 @@
:scm_revision => ENV['REVISION'],
:scm_repository => ENV['REPO'],
:local_username => ENV['USER'],
:api_key => ENV['API_KEY'])
:api_key => ENV['API_KEY'],
:dry_run => ENV['DRY_RUN'])
end

task :log_stdout do
Expand Down
15 changes: 10 additions & 5 deletions lib/hoptoad_tasks.rb
Expand Up @@ -34,11 +34,16 @@ def self.deploy(opts = {})
HoptoadNotifier.configuration.proxy_port,
HoptoadNotifier.configuration.proxy_user,
HoptoadNotifier.configuration.proxy_pass)

response = proxy.post_form(url, params)

puts response.body
return Net::HTTPSuccess === response

if opts[:dry_run]
puts url, params.inspect
return true
else
response = proxy.post_form(url, params)

puts response.body
return Net::HTTPSuccess === response
end
end
end

8 changes: 8 additions & 0 deletions test/hoptoad_tasks_test.rb
Expand Up @@ -51,6 +51,14 @@ def unsuccessful_response(body = "")

@options = { :rails_env => "staging" }
end

context "performing a dry run" do
setup { @output = HoptoadTasks.deploy(@options.merge(:dry_run => true)) }

should "return true without performing any actual request" do
assert @output
end
end

context "on deploy(options)" do
setup do
Expand Down

0 comments on commit 496f12b

Please sign in to comment.