test: cover test_dispatch_emits_process_action_event_with_status

This commit is contained in:
dualfroz committed 2026-09-09 15:48:30 +02:00
1 parent f1a68f2534
commit 99bbae8099
3 files changed
+137

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
require 'minitest/autorun'
require 'prism'
require 'support'
class EchoMountedApp
def call(env)
[200, { 'Content-Type' => 'text/plain' },
["script_name=#{env['SCRIPT_NAME']} path_info=#{env['PATH_INFO']}"]]
end
end
class MountApp < Prism::Application
mount '/admin', EchoMountedApp.new
get '/host-route' do
'host app route'
end
end
class MountPrecedenceApp < Prism::Application
mount '/shared', EchoMountedApp.new
get '/shared' do
'host app route wins'
end
end
class ApplicationMountTest < Minitest::Test
include TestSupport
def test_mounted_app_receives_rewritten_script_name_and_path_info
status, _, body = MountApp.call(env_for('GET', '/admin/users/1'))
assert_equal 200, status
assert_equal 'script_name=/admin path_info=/users/1', body.join
end
def test_mounted_app_receives_root_path_info_at_bare_prefix
_, _, body = MountApp.call(env_for('GET', '/admin'))
assert_equal 'script_name=/admin path_info=/', body.join
end
def test_host_applications_own_routes_take_precedence_over_mounts
status, _, body = MountPrecedenceApp.call(env_for('GET', '/shared'))
assert_equal 200, status
assert_equal 'host app route wins', body.join
end
def test_unmatched_path_outside_any_mount_still_404s
status, = MountApp.call(env_for('GET', '/nowhere'))
assert_equal 404, status
end
end