Class: Heroku::Kensa::PlanChangeCheck
- Includes:
- HTTPForChecks
- Defined in:
- lib/heroku/kensa/check.rb
Instance Attribute Summary
Attributes inherited from Check
Instance Method Summary collapse
Methods included from HTTPForChecks
#delete, #get, #post, #put, #request
Methods inherited from ApiCheck
#base_path, #callback, #create_provision_payload, #credentials, #heroku_id
Methods inherited from Check
#api_requires?, #call, #check, #env, #error, #initialize, #run, #test, #to_proc, #url, #warning
Constructor Details
This class inherits a constructor from Heroku::Kensa::Check
Instance Method Details
#call! ⇒ Object
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
# File 'lib/heroku/kensa/check.rb', line 462 def call! id = data[:id] raise ArgumentError, "No id specified" if id.nil? new_plan = data[:plan] raise ArgumentError, "No plan specified" if new_plan.nil? path = "#{base_path}/#{CGI::escape(id.to_s)}" payload = {:plan => new_plan, :heroku_id => heroku_id} test "PUT #{path}" check "response" do payload[:uuid] = SecureRandom.uuid code, _ = put(credentials, path, payload) if code == 200 true elsif code == -1 error("unable to connect to #{url}") else error("expected 200, got #{code}") end end check "authentication" do wrong_credentials = ['wrong', 'secret'] payload[:uuid] = SecureRandom.uuid code, _ = put(wrong_credentials, path, payload) error("expected 401, got #{code}") if code != 401 true end end |