Sha256: 1a0fe0d73f2b322868c3eaf31dfb84a7f7bc96aaf8bf9098f9597e6c9e0b1b7a

Contents?: true

Size: 1.15 KB

Versions: 16

Compression:

Stored size: 1.15 KB

Contents

require 'test_helper'

class ThreadSafetyTest < ActionController::TestCase
  test "be thread safe when using #set_paper_trail_whodunnit" do
    blocked = true

    slow_thread = Thread.new do
      controller = TestController.new
      controller.send :set_paper_trail_whodunnit
      begin
        sleep 0.001
      end while blocked
      PaperTrail.whodunnit
    end

    fast_thread = Thread.new do
      controller = TestController.new
      controller.send :set_paper_trail_whodunnit
      who = PaperTrail.whodunnit
      blocked = false
      who
    end

    assert_not_equal slow_thread.value, fast_thread.value
  end

  test "be thread safe when using #without_versioning" do
    enabled = nil

    slow_thread = Thread.new do
      Widget.new.without_versioning do
        sleep(0.01)
        enabled = Widget.paper_trail_enabled_for_model?
        sleep(0.01)
      end
      enabled
    end

    fast_thread = Thread.new do
      sleep(0.005)
      Widget.paper_trail_enabled_for_model?
    end

    assert_not_equal slow_thread.value, fast_thread.value
    assert Widget.paper_trail_enabled_for_model?
    assert PaperTrail.enabled_for_model?(Widget)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
paper_trail-4.2.0 test/functional/thread_safety_test.rb
paper_trail-4.1.0 test/functional/thread_safety_test.rb
paper_trail-4.0.2 test/functional/thread_safety_test.rb
paper_trail-4.0.1 test/functional/thread_safety_test.rb
paper_trail-3.0.9 test/functional/thread_safety_test.rb
paper_trail-4.0.0 test/functional/thread_safety_test.rb
paper_trail-4.0.0.rc2 test/functional/thread_safety_test.rb
paper_trail-4.0.0.rc1 test/functional/thread_safety_test.rb
paper_trail-3.0.8 test/functional/thread_safety_test.rb
paper_trail-3.0.7 test/functional/thread_safety_test.rb
paper_trail-4.0.0.beta2 test/functional/thread_safety_test.rb
paper_trail-4.0.0.beta1 test/functional/thread_safety_test.rb
paper_trail-3.0.6 test/functional/thread_safety_test.rb
paper_trail-3.0.5 test/functional/thread_safety_test.rb
paper_trail-3.0.2 test/functional/thread_safety_test.rb
paper_trail-3.0.1 test/functional/thread_safety_test.rb