1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00
paper-trail-gem--paper_trail/test/functional/thread_safety_test.rb
2011-02-08 17:16:35 +00:00

26 lines
572 B
Ruby

require 'test_helper'
class ThreadSafetyTest < ActionController::TestCase
should "be thread safe" do
blocked = true
slow_thread = Thread.new do
controller = TestController.new
controller.send :set_whodunnit
begin
sleep 0.001
end while blocked
PaperTrail.whodunnit
end
fast_thread = Thread.new do
controller = TestController.new
controller.send :set_whodunnit
who = PaperTrail.whodunnit
blocked = false
who
end
assert_not_equal slow_thread.value, fast_thread.value
end
end