diff options
author | Jon Leighton <j@jonathanleighton.com> | 2013-01-18 16:07:07 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2013-01-18 16:07:07 +0000 |
commit | 1d55e07ff9531890a54d8dc0449e848352064e9e (patch) | |
tree | 3fec808b6933719d00c95bcfc1806fe61ca35a70 /activesupport/lib | |
parent | 227cfe50c60190428be3a0b4ed4521a283ee03cf (diff) | |
download | rails-1d55e07ff9531890a54d8dc0449e848352064e9e.tar.gz rails-1d55e07ff9531890a54d8dc0449e848352064e9e.tar.bz2 rails-1d55e07ff9531890a54d8dc0449e848352064e9e.zip |
The test setup is not threadsafe. Wrap in a mutex.
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/testing/isolation.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/testing/isolation.rb b/activesupport/lib/active_support/testing/isolation.rb index f7a92ce03b..e4f8959e7a 100644 --- a/activesupport/lib/active_support/testing/isolation.rb +++ b/activesupport/lib/active_support/testing/isolation.rb @@ -88,10 +88,14 @@ module ActiveSupport !ENV["NO_FORK"] && ((RbConfig::CONFIG['host_os'] !~ /mswin|mingw/) && (RUBY_PLATFORM !~ /java/)) end + @@class_setup_mutex = Mutex.new + def _run_class_setup # class setup method should only happen in parent - unless defined?(@@ran_class_setup) || ENV['ISOLATION_TEST'] - self.class.setup if self.class.respond_to?(:setup) - @@ran_class_setup = true + @@class_setup_mutex.synchronize do + unless defined?(@@ran_class_setup) || ENV['ISOLATION_TEST'] + self.class.setup if self.class.respond_to?(:setup) + @@ran_class_setup = true + end end end |