Skip to content

Commit

Permalink
Bugfixes to deploy task
Browse files Browse the repository at this point in the history
  • Loading branch information
Tammer Saleh committed Mar 23, 2009
1 parent e4dbd3d commit 9cdd038
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/hoptoad_tasks.rb
Expand Up @@ -10,12 +10,12 @@ def self.deploy_to(rails_env)
end

if rails_env.blank?
puts "I don't know to which Rails environment you are deploying (use the TO='production' option)."
puts "I don't know to which Rails environment you are deploying (use the TO=production option)."
return false
end

url = URI.parse("http://hoptoadapp.com/deploys")
response = Net::HTTP.post_form(url, :api_key => HoptoadNotifier.api_key, :deploy => {:rails_env => rails_env})
url = URI.parse("http://#{HoptoadNotifier.host}/deploys")
response = Net::HTTP.post_form(url, :api_key => HoptoadNotifier.api_key, "deploy[rails_env]" => rails_env)
puts response.body
return Net::HTTPSuccess === response
end
Expand Down
2 changes: 1 addition & 1 deletion tasks/hoptoad_notifier_tasks.rake
Expand Up @@ -2,7 +2,7 @@ namespace :hoptoad do
desc "Notify Hoptoad of a new deploy."
task :deploy => :environment do
require 'hoptoad_tasks'
HoptoadTasks.create_deploy(ENV['TO'])
HoptoadTasks.deploy_to(ENV['TO'])
end

desc "Verify your plugin installation by sending a test exception to the hoptoad service"
Expand Down
23 changes: 20 additions & 3 deletions test/hoptoad_tasks_test.rb
Expand Up @@ -51,10 +51,9 @@ def unsuccessful_response(body = "")
returns(successful_response)
end

before_should "use valid deploy params" do
deploy_params = {:rails_env => "staging"}
before_should "use send the rails_env param" do
Net::HTTP.expects(:post_form).
with(kind_of(URI), has_entries(:deploy => deploy_params)).
with(kind_of(URI), has_entries("deploy[rails_env]" => "staging")).
returns(successful_response)
end

Expand Down Expand Up @@ -82,6 +81,24 @@ def unsuccessful_response(body = "")
end
end

context "in a configured project with custom host" do
setup do
HoptoadNotifier.configure do |config|
config.api_key = "1234123412341234"
config.host = "custom.host"
end
end

context "on deploy_to('staging')" do
setup { @output = HoptoadTasks.deploy_to("staging") }

before_should "post to the custom host" do
URI.stubs(:parse).with('http://custom.host/deploys').returns(:uri)
Net::HTTP.expects(:post_form).with(:uri, kind_of(Hash)).returns(successful_response)
end
end
end

context "when not configured" do
setup { HoptoadNotifier.configure { |config| config.api_key = "" } }

Expand Down

0 comments on commit 9cdd038

Please sign in to comment.