Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Run kumade:post_deploy if deployment succeeds.

  • Loading branch information...
commit 967901842e22bbf94804b4ce8d00b6c74620bf24 1 parent 81eb06c
@hoverlover hoverlover authored
View
3  README.md
@@ -14,7 +14,8 @@ After that, it packages assets using
[Jammit](http://documentcloud.github.com/jammit/) (if it's installed), commits
them, and pushes to origin.
Then it force pushes to the correct Heroku remote, runs `rake db:migrate` on the
-Heroku app, and then restarts the app.
+Heroku app, and then restarts the app. If all of this succeeds, it will
+also run the rake task `kumade:post_deploy` if it is defined.
If any step fails, it immediately prints an error and stops the deploy
process.
View
9 lib/kumade/deployer.rb
@@ -19,6 +19,7 @@ def deploy
heroku.sync
heroku.migrate_database
heroku.restart_app
+ post_deploy_success
rescue => deploying_error
Kumade.configuration.outputter.error("#{deploying_error.class}: #{deploying_error.message}")
ensure
@@ -33,6 +34,10 @@ def pre_deploy
sync_origin
end
+ def post_deploy_success
+ run_postdeploy_task
+ end
+
def package_assets
@packager.run
end
@@ -66,5 +71,9 @@ def ensure_heroku_remote_exists
def run_predeploy_task
RakeTaskRunner.new("kumade:pre_deploy").invoke
end
+
+ def run_postdeploy_task
+ RakeTaskRunner.new("kumade:post_deploy").invoke
+ end
end
end
View
22 spec/kumade/deployer_spec.rb
@@ -26,6 +26,27 @@
end
end
+describe Kumade::Deployer, "#post_deploy_success", :with_mock_outputter do
+ let(:rake_task_runner) { stub("RakeTaskRunner", :invoke => true) }
+
+ before do
+ Kumade::RakeTaskRunner.stubs(:new).with("kumade:post_deploy").returns(rake_task_runner)
+ end
+
+ it "calls the correct methods" do
+ subject.expects(:run_postdeploy_task)
+
+ subject.post_deploy_success
+ end
+
+ it "invokes the kumade:pre_deploy task" do
+ subject.post_deploy_success
+
+ Kumade::RakeTaskRunner.should have_received(:new).with("kumade:post_deploy")
+ rake_task_runner.should have_received(:invoke)
+ end
+end
+
describe Kumade::Deployer, "#deploy", :with_mock_outputter do
let(:remote_name) { 'staging' }
@@ -39,6 +60,7 @@
subject.heroku.expects(:migrate_database)
subject.heroku.expects(:restart_app)
subject.expects(:post_deploy)
+ subject.expects(:post_deploy_success)
subject.deploy
end
Please sign in to comment.
Something went wrong with that request. Please try again.