2008-10-27 07:47:01 +01:00
|
|
|
require 'abstract_unit'
|
|
|
|
require 'action_controller'
|
2009-02-04 21:26:08 +01:00
|
|
|
require 'action_controller/test_case'
|
2008-10-27 07:47:01 +01:00
|
|
|
|
|
|
|
RAILS_ENV = "test"
|
|
|
|
CURRENT_DIR = File.expand_path(File.dirname(__FILE__))
|
|
|
|
HTML_DIR = File.expand_path(File.join(CURRENT_DIR, "..", "html"))
|
|
|
|
|
|
|
|
module Rails
|
|
|
|
def self.public_path
|
|
|
|
CURRENT_DIR
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class ErrorPageController < ActionController::Base
|
|
|
|
def crash
|
|
|
|
raise StandardError, "crash!"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
ActionController::Routing::Routes.draw do |map|
|
|
|
|
map.connect ':controller/:action/:id'
|
|
|
|
end
|
|
|
|
|
2009-02-04 21:26:08 +01:00
|
|
|
class ErrorPageControllerTest < ActionController::TestCase
|
2008-10-27 07:47:01 +01:00
|
|
|
def setup
|
|
|
|
ActionController::Base.consider_all_requests_local = false
|
2009-02-04 21:26:08 +01:00
|
|
|
rescue_action_in_public!
|
2008-10-27 07:47:01 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_500_error_page_instructs_system_administrator_to_check_log_file
|
|
|
|
template = ERB.new(File.read(File.join(HTML_DIR, "500.html")))
|
|
|
|
File.open(File.join(CURRENT_DIR, "500.html"), "w") do |f|
|
|
|
|
f.write(template.result)
|
|
|
|
end
|
|
|
|
get :crash
|
|
|
|
expected_log_file = "#{RAILS_ENV}.log"
|
2009-02-04 21:26:08 +01:00
|
|
|
assert_not_nil @response.body.index(expected_log_file), @response.body
|
2008-10-27 07:47:01 +01:00
|
|
|
end
|
|
|
|
end
|