Class: Heroku::Kensa::PlanChangeCheck

Inherits:
ApiCheck show all
Includes:
HTTP
Defined in:
lib/heroku/kensa/check.rb

Instance Attribute Summary

Attributes inherited from Check

#data, #screen

Instance Method Summary collapse

Methods included from HTTP

#delete, #get, #post, #put, #request

Methods inherited from ApiCheck

#base_path, #credentials, #heroku_id

Methods inherited from Check

#call, #check, #env, #error, #initialize, #run, #test, #to_proc, #url

Constructor Details

This class inherits a constructor from Heroku::Kensa::Check

Instance Method Details

#call!Object

Raises:

  • (ArgumentError)


393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/heroku/kensa/check.rb', line 393

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
    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']
    code, _ = put(wrong_credentials, path, payload)
    error("expected 401, got #{code}") if code != 401
    true
  end
end