aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/show_exceptions_test.rb
diff options
context:
space:
mode:
authorlest <just.lest@gmail.com>2011-11-22 11:24:05 +0300
committerlest <just.lest@gmail.com>2011-11-22 11:38:55 +0300
commitc6d6b28bb4e105fd0ae7a0ef3c7df4bc416bd397 (patch)
tree1cde72184a51b79ce4026cc9c175f7ba863051b7 /actionpack/test/controller/show_exceptions_test.rb
parenta9e8cf78fda696738f63e726796f6232c3751603 (diff)
downloadrails-c6d6b28bb4e105fd0ae7a0ef3c7df4bc416bd397.tar.gz
rails-c6d6b28bb4e105fd0ae7a0ef3c7df4bc416bd397.tar.bz2
rails-c6d6b28bb4e105fd0ae7a0ef3c7df4bc416bd397.zip
refactor show exceptions tests
Diffstat (limited to 'actionpack/test/controller/show_exceptions_test.rb')
-rw-r--r--actionpack/test/controller/show_exceptions_test.rb59
1 files changed, 59 insertions, 0 deletions
diff --git a/actionpack/test/controller/show_exceptions_test.rb b/actionpack/test/controller/show_exceptions_test.rb
new file mode 100644
index 0000000000..c328a42e89
--- /dev/null
+++ b/actionpack/test/controller/show_exceptions_test.rb
@@ -0,0 +1,59 @@
+require 'abstract_unit'
+
+module ShowExceptions
+ class ShowExceptionsController < ActionController::Metal
+ use ActionDispatch::ShowExceptions
+
+ def boom
+ raise 'boom!'
+ end
+ end
+
+ class ShowExceptionsTest < ActionDispatch::IntegrationTest
+ test 'show error page from a remote ip' do
+ @app = ShowExceptionsController.action(:boom)
+ self.remote_addr = '208.77.188.166'
+ get '/'
+ assert_equal "500 error fixture\n", body
+ end
+
+ test 'show diagnostics from a local ip' do
+ @app = ShowExceptionsController.action(:boom)
+ ['127.0.0.1', '127.0.0.127', '::1', '0:0:0:0:0:0:0:1', '0:0:0:0:0:0:0:1%0'].each do |ip_address|
+ self.remote_addr = ip_address
+ get '/'
+ assert_match /boom/, body
+ end
+ end
+
+ test 'show diagnostics from a remote ip when consider_all_requests_local is true' do
+ Rails.stubs(:application).returns stub(:config => stub(:consider_all_requests_local => true))
+ @app = ShowExceptionsController.action(:boom)
+ self.remote_addr = '208.77.188.166'
+ get '/'
+ assert_match /boom/, body
+ end
+ end
+
+ class ShowExceptionsOverridenController < ShowExceptionsController
+ private
+
+ def show_detailed_exceptions?
+ params['detailed'] == '1'
+ end
+ end
+
+ class ShowExceptionsOverridenTest < ActionDispatch::IntegrationTest
+ test 'show error page' do
+ @app = ShowExceptionsOverridenController.action(:boom)
+ get '/', {'detailed' => '0'}
+ assert_equal "500 error fixture\n", body
+ end
+
+ test 'show diagnostics message' do
+ @app = ShowExceptionsOverridenController.action(:boom)
+ get '/', {'detailed' => '1'}
+ assert_match /boom/, body
+ end
+ end
+end