Sha256: 0039550af39d76678113a6f68d9ef567e5dec46cbef4530d7b77766b2706be60

Contents?: true

Size: 572 Bytes

Versions: 33

Compression:

Stored size: 572 Bytes

Contents

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

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
paper_trail-2.7.2 test/functional/thread_safety_test.rb
paper_trail-2.7.1 test/functional/thread_safety_test.rb
paper_trail-2.7.0 test/functional/thread_safety_test.rb
paper_trail-2.6.4 test/functional/thread_safety_test.rb
paper_trail-2.6.3 test/functional/thread_safety_test.rb
paper_trail-2.6.2 test/functional/thread_safety_test.rb
paper_trail-2.6.1 test/functional/thread_safety_test.rb
paper_trail-2.6.0 test/functional/thread_safety_test.rb
paper_trail-2.5.2 test/functional/thread_safety_test.rb
paper_trail-2.5.0 test/functional/thread_safety_test.rb
paper_trail-2.4.1 test/functional/thread_safety_test.rb
paper_trail-2.4.0 test/functional/thread_safety_test.rb
bkwld-paper_trail-2.3.3 test/functional/thread_safety_test.rb
paper_trail-2.3.3 test/functional/thread_safety_test.rb
bkwld-paper_trail-2.3.2 test/functional/thread_safety_test.rb
paper_trail-2.3.2 test/functional/thread_safety_test.rb
paper_trail-2.3.1 test/functional/thread_safety_test.rb
paper_trail-2.3.0 test/functional/thread_safety_test.rb
paper_trail-2.2.9 test/functional/thread_safety_test.rb
paper_trail-2.2.8 test/functional/thread_safety_test.rb