Sha256: 7098d4c9079546bcb8ea5c516b16c15dc7347895434bcb2ce59ada79950b193d

Contents?: true

Size: 570 Bytes

Versions: 4

Compression:

Stored size: 570 Bytes

Contents

require 'test_helper'

class ThreadSafetyTest < ActionController::TestCase
  test "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

4 entries across 4 versions & 2 rubygems

Version Path
paper_trail-3.0.0.rc2 test/functional/thread_safety_test.rb
paper_trail-3.0.0.rc1 test/functional/thread_safety_test.rb
paper_trail_without_deprecated-3.0.0.beta1 test/functional/thread_safety_test.rb
paper_trail-3.0.0.beta1 test/functional/thread_safety_test.rb