diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-09-08 05:32:16 -0700 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-09-08 05:32:16 -0700 |
commit | 2b41343c34bcbe809537590152506690b84832df (patch) | |
tree | 69f539c5aac0ff73901eac2df5512b0cb9d3f947 /activesupport/lib | |
parent | c3207a12be646483e7e0ce8c916e730e7ea5070d (diff) | |
download | rails-2b41343c34bcbe809537590152506690b84832df.tar.gz rails-2b41343c34bcbe809537590152506690b84832df.tar.bz2 rails-2b41343c34bcbe809537590152506690b84832df.zip |
Default to sorting user's test cases for now
Goals:
1. Default to :random for newly generated applications
2. Default to :sorted for existing applications with a warning
3. Only show the warning once
4. Only show the warning if the app actually uses AS::TestCase
Fixes #16769
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/test_case.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb index 0df599b692..33139320fa 100644 --- a/activesupport/lib/active_support/test_case.rb +++ b/activesupport/lib/active_support/test_case.rb @@ -12,10 +12,42 @@ require 'active_support/core_ext/kernel/reporting' require 'active_support/deprecation' module ActiveSupport + class << self + delegate :test_order, :test_order=, to: :'ActiveSupport::TestCase' + end + class TestCase < ::Minitest::Test Assertion = Minitest::Assertion + @@test_order = nil + class << self + def test_order=(new_order) + @@test_order = new_order + end + + def test_order + if @@test_order.nil? + ActiveSupport::Deprecation.warn "You did not specify a value for the " \ + "configuration option 'active_support.test_order'. In Rails 5.0, " \ + "the default value of this option will change from `:sorted` to " \ + "`:random`.\n" \ + "To disable this warning and keep the current behavior, you can add " \ + "the following line to your `config/environments/test.rb`:\n" \ + "\n" \ + " Rails.application.configure do\n" \ + " config.active_support.test_order = :sorted\n" \ + " end\n" \ + "\n" \ + "Alternatively, you can opt into the future behavior by setting this " \ + "option to `:random`." + + @@test_order = :sorted + end + + @@test_order + end + alias :my_tests_are_order_dependent! :i_suck_and_my_tests_are_order_dependent! end |