Permalink
Browse files

add maintenance command to display apps maintenance status

closes #471
  • Loading branch information...
1 parent 2b8b5b5 commit 07676055c7aeb95c4834350e500a545d5b4523e8 @geemus geemus committed Jul 20, 2012
Showing with 42 additions and 4 deletions.
  1. +2 −2 Gemfile.lock
  2. +1 −1 heroku.gemspec
  3. +21 −1 lib/heroku/command/maintenance.rb
  4. +18 −0 spec/heroku/command/maintenance_spec.rb
View
4 Gemfile.lock
@@ -2,7 +2,7 @@ PATH
remote: .
specs:
heroku (2.29.0)
- heroku-api (~> 0.3.0)
+ heroku-api (~> 0.3.1)
launchy (>= 0.3.2)
netrc (~> 0.7.5)
rest-client (~> 1.6.1)
@@ -23,7 +23,7 @@ GEM
fakefs (0.4.0)
fpm (0.3.11)
json
- heroku-api (0.3.0)
+ heroku-api (0.3.1)
excon (~> 0.15.4)
json (1.6.5)
launchy (2.1.0)
View
2 heroku.gemspec
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
gem.files = %x{ git ls-files }.split("\n").select { |d| d =~ %r{^(License|README|bin/|data/|ext/|lib/|spec/|test/)} }
- gem.add_dependency "heroku-api", "~> 0.3.0"
+ gem.add_dependency "heroku-api", "~> 0.3.1"
gem.add_dependency "netrc", "~> 0.7.5"
gem.add_dependency "rest-client", "~> 1.6.1"
gem.add_dependency "launchy", ">= 0.3.2"
View
22 lib/heroku/command/maintenance.rb
@@ -1,9 +1,29 @@
require "heroku/command/base"
-# toggle maintenance mode
+# manage maintenance mode for an app
#
class Heroku::Command::Maintenance < Heroku::Command::Base
+ # maintenance
+ #
+ # display the current maintenance status of app
+ #
+ #Example:
+ #
+ # $ heroku maintenance
+ # off
+ #
+ def index
+ validate_arguments!
+
+ case api.get_app_maintenance(app).body['maintenance']
+ when true
+ display('on')
+ when false
+ display('off')
+ end
+ end
+
# maintenance:on
#
# put the app into maintenance mode
View
18 spec/heroku/command/maintenance_spec.rb
@@ -13,6 +13,24 @@ module Heroku::Command
api.delete_app("myapp")
end
+ it "displays off for maintenance mode of an app" do
+ stderr, stdout = execute("maintenance")
+ stderr.should == ""
+ stdout.should == <<-STDOUT
+off
+STDOUT
+ end
+
+ it "displays on for maintenance mode of an app" do
+ api.post_app_maintenance('myapp', '1')
+
+ stderr, stdout = execute("maintenance")
+ stderr.should == ""
+ stdout.should == <<-STDOUT
+on
+STDOUT
+ end
+
it "turns on maintenance mode for the app" do
stderr, stdout = execute("maintenance:on")
stderr.should == ""

0 comments on commit 0767605

Please sign in to comment.