3
3
class ShowExceptionsTest < ActionDispatch ::IntegrationTest
4
4
5
5
class Boomer
6
- def initialize ( show_exceptions = false )
7
- @show_exceptions = show_exceptions
6
+ def initialize ( detailed = false )
7
+ @detailed = detailed
8
8
end
9
9
10
10
def call ( env )
11
- env [ 'action_dispatch.show_exceptions ' ] = @show_exceptions
11
+ env [ 'action_dispatch.show_detailed_exceptions ' ] = @detailed
12
12
req = ActionDispatch ::Request . new ( env )
13
13
case req . path
14
14
when "/not_found"
@@ -32,9 +32,8 @@ def call(env)
32
32
ProductionApp = ActionDispatch ::ShowExceptions . new ( Boomer . new ( false ) )
33
33
DevelopmentApp = ActionDispatch ::ShowExceptions . new ( Boomer . new ( true ) )
34
34
35
- test "rescue in public from a remote ip " do
35
+ test "rescue with error page when show_exceptions is false " do
36
36
@app = ProductionApp
37
- self . remote_addr = '208.77.188.166'
38
37
39
38
get "/" , { } , { 'action_dispatch.show_exceptions' => true }
40
39
assert_response 500
@@ -49,32 +48,28 @@ def call(env)
49
48
assert_equal "" , body
50
49
end
51
50
52
- test "rescue locally from a local request" do
53
- @app = ProductionApp
54
- [ '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 |
55
- self . remote_addr = ip_address
51
+ test "rescue with diagnostics message when show_exceptions is true" do
52
+ @app = DevelopmentApp
56
53
57
- get "/" , { } , { 'action_dispatch.show_exceptions' => true }
58
- assert_response 500
59
- assert_match ( /puke/ , body )
54
+ get "/" , { } , { 'action_dispatch.show_exceptions' => true }
55
+ assert_response 500
56
+ assert_match ( /puke/ , body )
60
57
61
- get "/not_found" , { } , { 'action_dispatch.show_exceptions' => true }
62
- assert_response 404
63
- assert_match ( /#{ ActionController ::UnknownAction . name } / , body )
58
+ get "/not_found" , { } , { 'action_dispatch.show_exceptions' => true }
59
+ assert_response 404
60
+ assert_match ( /#{ ActionController ::UnknownAction . name } / , body )
64
61
65
- get "/method_not_allowed" , { } , { 'action_dispatch.show_exceptions' => true }
66
- assert_response 405
67
- assert_match ( /ActionController::MethodNotAllowed/ , body )
68
- end
62
+ get "/method_not_allowed" , { } , { 'action_dispatch.show_exceptions' => true }
63
+ assert_response 405
64
+ assert_match ( /ActionController::MethodNotAllowed/ , body )
69
65
end
70
66
71
- test "localize public rescue message " do
67
+ test "localize rescue error page " do
72
68
# Change locale
73
69
old_locale , I18n . locale = I18n . locale , :da
74
70
75
71
begin
76
72
@app = ProductionApp
77
- self . remote_addr = '208.77.188.166'
78
73
79
74
get "/" , { } , { 'action_dispatch.show_exceptions' => true }
80
75
assert_response 500
@@ -88,23 +83,6 @@ def call(env)
88
83
end
89
84
end
90
85
91
- test "always rescue locally in development mode" do
92
- @app = DevelopmentApp
93
- self . remote_addr = '208.77.188.166'
94
-
95
- get "/" , { } , { 'action_dispatch.show_exceptions' => true }
96
- assert_response 500
97
- assert_match ( /puke/ , body )
98
-
99
- get "/not_found" , { } , { 'action_dispatch.show_exceptions' => true }
100
- assert_response 404
101
- assert_match ( /#{ ActionController ::UnknownAction . name } / , body )
102
-
103
- get "/method_not_allowed" , { } , { 'action_dispatch.show_exceptions' => true }
104
- assert_response 405
105
- assert_match ( /ActionController::MethodNotAllowed/ , body )
106
- end
107
-
108
86
test "does not show filtered parameters" do
109
87
@app = DevelopmentApp
110
88
@@ -114,16 +92,15 @@ def call(env)
114
92
assert_match ( ""foo"=>"[FILTERED]"" , body )
115
93
end
116
94
117
- test "show registered original exception for wrapped exceptions when consider_all_requests_local is false" do
95
+ test "show registered original exception for wrapped exceptions when show_exceptions is false" do
118
96
@app = ProductionApp
119
- self . remote_addr = '208.77.188.166'
120
97
121
98
get "/not_found_original_exception" , { } , { 'action_dispatch.show_exceptions' => true }
122
99
assert_response 404
123
100
assert_match ( /404 error/ , body )
124
101
end
125
102
126
- test "show registered original exception for wrapped exceptions when consider_all_requests_local is true" do
103
+ test "show registered original exception for wrapped exceptions when show_exceptions is true" do
127
104
@app = DevelopmentApp
128
105
129
106
get "/not_found_original_exception" , { } , { 'action_dispatch.show_exceptions' => true }
@@ -132,7 +109,7 @@ def call(env)
132
109
end
133
110
134
111
test "show the controller name in the diagnostics template when controller name is present" do
135
- @app = ProductionApp
112
+ @app = DevelopmentApp
136
113
get ( "/runtime_error" , { } , {
137
114
'action_dispatch.show_exceptions' => true ,
138
115
'action_dispatch.request.parameters' => {
0 commit comments