aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-04-27 16:20:16 -0400
committerGitHub <noreply@github.com>2018-04-27 16:20:16 -0400
commitbb2a3afafbcdfac3294479f042cb7a8f7f3d6739 (patch)
tree969200c34176d382da84ba5f13cea0985ecce252 /activesupport/lib
parentad0220a71a2d42191a3acf6118321b504f1ad70c (diff)
parent1cf8b6c23120e24707a2606a4b159a56faf38212 (diff)
downloadrails-bb2a3afafbcdfac3294479f042cb7a8f7f3d6739.tar.gz
rails-bb2a3afafbcdfac3294479f042cb7a8f7f3d6739.tar.bz2
rails-bb2a3afafbcdfac3294479f042cb7a8f7f3d6739.zip
Merge pull request #32733 from Edouard-chin/ec-setupand-teardown
`SetupAndTeardown` has few caveats that breaks libraries
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/test_case.rb2
-rw-r--r--activesupport/lib/active_support/testing/setup_and_teardown.rb14
2 files changed, 6 insertions, 10 deletions
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb
index 4e42db4500..f17743b6db 100644
--- a/activesupport/lib/active_support/test_case.rb
+++ b/activesupport/lib/active_support/test_case.rb
@@ -130,7 +130,7 @@ module ActiveSupport
alias_method :method_name, :name
include ActiveSupport::Testing::TaggedLogging
- include ActiveSupport::Testing::SetupAndTeardown
+ prepend ActiveSupport::Testing::SetupAndTeardown
include ActiveSupport::Testing::Assertions
include ActiveSupport::Testing::Deprecation
include ActiveSupport::Testing::TimeHelpers
diff --git a/activesupport/lib/active_support/testing/setup_and_teardown.rb b/activesupport/lib/active_support/testing/setup_and_teardown.rb
index 35236f1401..35321cd157 100644
--- a/activesupport/lib/active_support/testing/setup_and_teardown.rb
+++ b/activesupport/lib/active_support/testing/setup_and_teardown.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true
-require "active_support/concern"
require "active_support/callbacks"
module ActiveSupport
@@ -19,11 +18,10 @@ module ActiveSupport
# end
# end
module SetupAndTeardown
- extend ActiveSupport::Concern
-
- included do
- include ActiveSupport::Callbacks
- define_callbacks :setup, :teardown
+ def self.prepended(klass)
+ klass.include ActiveSupport::Callbacks
+ klass.define_callbacks :setup, :teardown
+ klass.extend ClassMethods
end
module ClassMethods
@@ -47,12 +45,10 @@ module ActiveSupport
begin
run_callbacks :teardown
rescue => e
- error = e
+ self.failures << Minitest::UnexpectedError.new(e)
end
super
- ensure
- raise error if error
end
end
end