Skip to content
This repository
Browse code

allow --confirm to set --app

  • Loading branch information...
commit 32043a97a37ddb99dba6367fff97d37c66ce0033 1 parent 2655c14
Chris Continanza csquared authored

Showing 2 changed files with 24 additions and 3 deletions. Show diff stats Hide diff stats

  1. +9 0 lib/heroku/command/base.rb
  2. +15 3 spec/heroku/command_spec.rb
9 lib/heroku/command/base.rb
@@ -147,9 +147,18 @@ def extract_option(name, default=true)
147 147 block_given? ? yield(value) : value
148 148 end
149 149
  150 + def confirm_mismatch?
  151 + options[:confirm] && (options[:confirm] != options[:app])
  152 + end
  153 +
150 154 def extract_app
151 155 if options[:app].is_a?(String)
  156 + if confirm_mismatch?
  157 + raise Heroku::Command::CommandFailed, "Mismtach between --app and --confirm"
  158 + end
152 159 options[:app]
  160 + elsif options[:confirm].is_a?(String)
  161 + options[:confirm]
153 162 elsif app_from_dir = extract_app_in_dir(Dir.pwd)
154 163 app_from_dir
155 164 else
18 spec/heroku/command_spec.rb
@@ -13,14 +13,26 @@
13 13 :body => 'terms of service required'}
14 14 end
15 15
16   - ## scheduled to be done by addons team story 18664983
17 16 context "when the app is unknown" do
18 17 context "and the user includes --confirm APP" do
19   - it "should set --app to APP and not ask for confirmation"
  18 + it "should set --app to APP and not ask for confirmation" do
  19 + stub_request(:post, %r{apps/XXX/addons/my_addon$})
  20 + .with(:body => {:confirm => "XXX"})
  21 + run "addons:add my_addon --confirm XXX"
  22 + end
20 23 end
21 24
22 25 context "and the user includes --confirm APP --app APP2" do
23   - it "should warn that the app and confirm do not match and not continue"
  26 + before do
  27 + # mock(Heroku::Command).error doesn't work
  28 + klass = Heroku::Command
  29 + def klass.error(msg)
  30 + raise StandardError unless msg = "Mismatch between --app and --confirm"
  31 + end
  32 + end
  33 + it "should warn that the app and confirm do not match and not continue" do
  34 + run "addons:add my_addon --confirm APP --app APP2"
  35 + end
24 36 end
25 37 end
26 38

0 comments on commit 32043a9

Please sign in to comment.
Something went wrong with that request. Please try again.