aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-12-12 16:23:31 +0900
committerGitHub <noreply@github.com>2017-12-12 16:23:31 +0900
commit38b2904f2c9d89868e96edd71c5f3143ca235a88 (patch)
treeca1ce30e4b3530ffe4943a9d38e8407315ca297c
parent84194ecd6201fa1af09f1e550ed0d9c7d3f5a49f (diff)
parent6122d2bfdf09fb4a3e70d619556ef471be274169 (diff)
downloadrails-38b2904f2c9d89868e96edd71c5f3143ca235a88.tar.gz
rails-38b2904f2c9d89868e96edd71c5f3143ca235a88.tar.bz2
rails-38b2904f2c9d89868e96edd71c5f3143ca235a88.zip
Merge pull request #31411 from eugeneius/time_helpers_redefine_method
Prevent race condition when resetting time stubs
-rw-r--r--activesupport/lib/active_support/testing/time_helpers.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/testing/time_helpers.rb b/activesupport/lib/active_support/testing/time_helpers.rb
index 8c620e7f8c..998a51a34c 100644
--- a/activesupport/lib/active_support/testing/time_helpers.rb
+++ b/activesupport/lib/active_support/testing/time_helpers.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
+require "active_support/core_ext/module/redefine_method"
require "active_support/core_ext/string/strip" # for strip_heredoc
require "active_support/core_ext/time/calculations"
require "concurrent/map"
@@ -43,7 +44,7 @@ module ActiveSupport
def unstub_object(stub)
singleton_class = stub.object.singleton_class
- singleton_class.send :undef_method, stub.method_name
+ singleton_class.send :silence_redefinition_of_method, stub.method_name
singleton_class.send :alias_method, stub.method_name, stub.original_method
singleton_class.send :undef_method, stub.original_method
end