@@ -20,20 +20,46 @@ def before_setup
2020 end
2121end
2222
23+ class RoutedRackApp
24+ class Config < Struct . new ( :middleware )
25+ end
26+
27+ attr_reader :routes
28+
29+ def initialize ( routes , &blk )
30+ @routes = routes
31+ @stack = ActionDispatch ::MiddlewareStack . new ( &blk )
32+ @app = @stack . build ( @routes )
33+ end
34+
35+ def call ( env )
36+ @app . call ( env )
37+ end
38+
39+ def config
40+ Config . new ( @stack )
41+ end
42+ end
43+
2344class ActionDispatch ::IntegrationTest < ActiveSupport ::TestCase
2445 include ActionDispatch ::SharedRoutes
2546
26- def self . build_app ( routes = nil )
47+ def self . build_app ( routes , options )
2748 RoutedRackApp . new ( routes || ActionDispatch ::Routing ::RouteSet . new ) do |middleware |
49+ middleware . use ActionDispatch ::Session ::ActiveRecordStore , options . reverse_merge ( :key => '_session_id' )
2850 middleware . use ActionDispatch ::DebugExceptions
51+ middleware . use ActionDispatch ::ActionableExceptions
2952 middleware . use ActionDispatch ::Callbacks
3053 middleware . use ActionDispatch ::Cookies
3154 middleware . use ActionDispatch ::Flash
55+ middleware . use Rack ::MethodOverride
3256 middleware . use Rack ::Head
3357 yield ( middleware ) if block_given?
3458 end
3559 end
3660
61+ self . app = build_app ( nil , { } )
62+
3763 private
3864
3965 def with_test_route_set ( options = { } )
@@ -45,11 +71,7 @@ def with_test_route_set(options = {})
4571 actions . each { |action | get action , controller : "#{ controller_namespace } /test" }
4672 end
4773
48- @app = self . class . build_app ( set ) do |middleware |
49- middleware . use ActionDispatch ::Session ::ActiveRecordStore , options . reverse_merge ( :key => '_session_id' )
50- middleware . delete ActionDispatch ::ShowExceptions
51- end
52-
74+ @app = self . class . build_app ( set , options )
5375 yield
5476 end
5577 end
@@ -63,17 +85,4 @@ def with_store(class_name)
6385 end
6486end
6587
66- class RoutedRackApp
67- attr_reader :routes
68-
69- def initialize ( routes , &blk )
70- @routes = routes
71- @stack = ActionDispatch ::MiddlewareStack . new ( &blk ) . build ( @routes )
72- end
73-
74- def call ( env )
75- @stack . call ( env )
76- end
77- end
78-
7988ActiveSupport ::TestCase . test_order = :random
0 commit comments