This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Allow passing an API_KEY as part of the hoptoad:deploy rake task

In certain complex situations, it's useful to be able to mark a project
as deployed when it's not part of a specific Rails app.
  • Loading branch information...
natacado authored and tristandunn committed Oct 12, 2009
1 parent 000e8bf commit 4d7181f33dab9bcf7b939af04257fa4a22cad1b8
Showing with 11 additions and 2 deletions.
  1. +2 −1 lib/hoptoad_tasks.rb
  2. +2 −1 tasks/hoptoad_notifier_tasks.rake
  3. +7 −0 test/hoptoad_tasks_test.rb
View
@@ -24,7 +24,8 @@ def self.deploy(opts = {})
return false
end
- params = {'api_key' => HoptoadNotifier.configuration.api_key}
+ params = {'api_key' => opts.delete(:api_key) ||
+ HoptoadNotifier.configuration.api_key}
opts.each {|k,v| params["deploy[#{k}]"] = v }
url = URI.parse("http://#{HoptoadNotifier.configuration.host || 'hoptoadapp.com'}/deploys.txt")
@@ -5,7 +5,8 @@ namespace :hoptoad do
HoptoadTasks.deploy(:rails_env => ENV['TO'],
:scm_revision => ENV['REVISION'],
:scm_repository => ENV['REPO'],
- :local_username => ENV['USER'])
+ :local_username => ENV['USER'],
+ :api_key => ENV['API_KEY'])
end
task :log_stdout do
@@ -69,6 +69,13 @@ def unsuccessful_response(body = "")
end
end
+ before_should "use the :api_key param if it's passed in." do
+ @options[:api_key] = "value"
+ Net::HTTP.expects(:post_form).
+ with(kind_of(URI), has_entries("api_key" => "value")).
+ returns(successful_response)
+ end
+
before_should "puts the response body on success" do
HoptoadTasks.expects(:puts).with("body")
Net::HTTP.expects(:post_form).with(any_parameters).returns(successful_response('body'))

0 comments on commit 4d7181f

Please sign in to comment.