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.2.7 test/functional/thread_safety_test.rb
paper_trail-2.2.6 test/functional/thread_safety_test.rb
paper_trail-2.2.5 test/functional/thread_safety_test.rb
paper_trail-2.2.4 test/functional/thread_safety_test.rb
paper_trail-2.2.3 test/functional/thread_safety_test.rb
paper_trail-2.2.2 test/functional/thread_safety_test.rb
paper_trail-2.2.1 test/functional/thread_safety_test.rb
paper_trail-2.2.0 test/functional/thread_safety_test.rb
paper_trail-2.1.1 test/functional/thread_safety_test.rb
paper_trail-2.1.0 test/functional/thread_safety_test.rb
paper_trail-2.0.2 test/functional/thread_safety_test.rb
paper_trail-2.0.1 test/functional/thread_safety_test.rb
paper_trail-2.0.0 test/functional/thread_safety_test.rb