@@ -44,7 +44,7 @@ def config
44
44
class ActionDispatch ::IntegrationTest < ActiveSupport ::TestCase
45
45
include ActionDispatch ::SharedRoutes
46
46
47
- def self . build_app ( routes , options )
47
+ def self . build_app ( routes = nil )
48
48
RoutedRackApp . new ( routes || ActionDispatch ::Routing ::RouteSet . new ) do |middleware |
49
49
middleware . use ActionDispatch ::DebugExceptions
50
50
middleware . use ActionDispatch ::ActionableExceptions
@@ -53,16 +53,25 @@ def self.build_app(routes, options)
53
53
middleware . use ActionDispatch ::Flash
54
54
middleware . use Rack ::MethodOverride
55
55
middleware . use Rack ::Head
56
- middleware . use ActionDispatch ::Session ::ActiveRecordStore , options . reverse_merge ( key : "_session_id" )
57
56
yield ( middleware ) if block_given?
58
57
end
59
58
end
60
59
61
- self . app = build_app ( nil , { } )
60
+ self . app = build_app
62
61
63
62
private
64
63
65
- def with_test_route_set ( options = { } )
64
+ def session_options ( options = { } )
65
+ ( @session_options ||= { key : "_session_id" } ) . merge! ( options )
66
+ end
67
+
68
+ def app
69
+ @app ||= self . class . build_app do |middleware |
70
+ middleware . use ActionDispatch ::Session ::ActiveRecordStore , session_options
71
+ end
72
+ end
73
+
74
+ def with_test_route_set
66
75
controller_namespace = self . class . to_s . underscore
67
76
actions = %w[ set_session_value get_session_value call_reset_session renew get_session_id ]
68
77
@@ -71,14 +80,7 @@ def with_test_route_set(options = {})
71
80
actions . each { |action | get action , controller : "#{ controller_namespace } /test" }
72
81
end
73
82
74
- old_app = self . class . app
75
- begin
76
- self . class . app = self . class . build_app ( set , options )
77
-
78
- yield
79
- ensure
80
- self . class . app = old_app
81
- end
83
+ yield
82
84
end
83
85
end
84
86
0 commit comments