mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
8536ebeefa
Without this, `DebugLocks` middleware raises an error as follwing: ``` Puma caught this error: can't modify frozen String (RuntimeError) actionpack/lib/action_dispatch/middleware/debug_locks.rb:97:in `block in render_details' actionpack/lib/action_dispatch/middleware/debug_locks.rb:64:in `each' actionpack/lib/action_dispatch/middleware/debug_locks.rb:64:in `map' actionpack/lib/action_dispatch/middleware/debug_locks.rb:64:in `render_details' actionpack/lib/action_dispatch/middleware/debug_locks.rb:37:in `call' railties/lib/rails/engine.rb:524:in `call' ```
38 lines
756 B
Ruby
38 lines
756 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "abstract_unit"
|
|
|
|
class DebugLocksTest < ActionDispatch::IntegrationTest
|
|
setup do
|
|
build_app
|
|
end
|
|
|
|
def test_render_threads_status
|
|
thread_ready = Concurrent::CountDownLatch.new
|
|
test_terminated = Concurrent::CountDownLatch.new
|
|
|
|
thread = Thread.new do
|
|
ActiveSupport::Dependencies.interlock.running do
|
|
thread_ready.count_down
|
|
test_terminated.wait
|
|
end
|
|
end
|
|
|
|
thread_ready.wait
|
|
|
|
get "/rails/locks"
|
|
|
|
test_terminated.count_down
|
|
|
|
assert_match(/Thread.*?Sharing/, @response.body)
|
|
ensure
|
|
thread.join
|
|
end
|
|
|
|
private
|
|
def build_app
|
|
@app = self.class.build_app do |middleware|
|
|
middleware.use ActionDispatch::DebugLocks
|
|
end
|
|
end
|
|
end
|