Skip to content

Commit e277341

Browse files
stevenharmanbyroot
authored andcommitted
Build an app instance compatible with with_routing
As of rails/rails#49819 the internals of `ActionDispatch::Assertions::RoutingAssertions` changed and the way we were building our app instance was no compatible with it. This gets us back to passing tests for Rails 7.2+. I hope 🤞
1 parent c19c5ea commit e277341

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

test/helper.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ class ActionDispatch::IntegrationTest < ActiveSupport::TestCase
4646

4747
def self.build_app(routes, options)
4848
RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware|
49-
middleware.use ActionDispatch::Session::ActiveRecordStore, options.reverse_merge(:key => '_session_id')
5049
middleware.use ActionDispatch::DebugExceptions
5150
middleware.use ActionDispatch::ActionableExceptions
5251
middleware.use ActionDispatch::Callbacks
5352
middleware.use ActionDispatch::Cookies
5453
middleware.use ActionDispatch::Flash
5554
middleware.use Rack::MethodOverride
5655
middleware.use Rack::Head
56+
middleware.use ActionDispatch::Session::ActiveRecordStore, options.reverse_merge(key: "_session_id")
5757
yield(middleware) if block_given?
5858
end
5959
end
@@ -71,7 +71,8 @@ def with_test_route_set(options = {})
7171
actions.each { |action| get action, controller: "#{controller_namespace}/test" }
7272
end
7373

74-
@app = self.class.build_app(set, options)
74+
self.class.app = self.class.build_app(set, options)
75+
7576
yield
7677
end
7778
end

test/logger_silencer_test.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ def setup
3939
def test_log_silencer_with_logger_not_raise_exception
4040
with_logger ActiveSupport::Logger.new(Tempfile.new("tempfile")) do
4141
with_test_route_set do
42-
get "/set_session_value"
42+
assert_nothing_raised do
43+
get "/set_session_value"
44+
end
4345
end
4446
end
4547
end

0 commit comments

Comments
 (0)