Skip to content

Commit

Permalink
Define the configuration at Active Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Mendonça França committed Sep 11, 2014
1 parent 8edb5ee commit 53e877f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
10 changes: 10 additions & 0 deletions activesupport/lib/active_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ def self.eager_load!

NumberHelper.eager_load!
end

@@test_order = nil

def self.test_order=(new_order)
@@test_order = new_order
end

def self.test_order
@@test_order
end
end

autoload :I18n, "active_support/i18n"
17 changes: 7 additions & 10 deletions activesupport/lib/active_support/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@
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
ActiveSupport.test_order = new_order
end

def test_order
if @@test_order.nil?
test_order = ActiveSupport.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 " \
Expand All @@ -42,10 +38,11 @@ def test_order
"Alternatively, you can opt into the future behavior by setting this " \
"option to `:random`."

@@test_order = :sorted
test_order = :sorted
self.test_order = test_order
end

@@test_order
test_order
end

alias :my_tests_are_order_dependent! :i_suck_and_my_tests_are_order_dependent!
Expand Down
1 change: 1 addition & 0 deletions railties/test/configuration/middleware_stack_proxy_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'active_support'
require 'active_support/testing/autorun'
require 'rails/configuration'
require 'active_support/test_case'
Expand Down
1 change: 1 addition & 0 deletions railties/test/isolation/abstract_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require 'fileutils'

require 'bundler/setup' unless defined?(Bundler)
require 'active_support'
require 'active_support/testing/autorun'
require 'active_support/test_case'

Expand Down

2 comments on commit 53e877f

@jonleighton
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafaelfranca FWIW the implication of this change is that whereas it was previously ok to just require active_support/test_case, it is now necessary to require active_support explicitly too. It broke Spring's tests: rails/spring@a3daa74 Not a massive issue but thought I'd point it out in case you want to add the active_support require into active_support/test_case.

@rafaelfranca
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah. I was in doubt when I did this change. Our guidelines says we always have to require the top level file of a framework when want to cherry-pick specific files. This is why I didn't add the require in active_support/test_case.

Our documentation already explain this guideline http://guides.rubyonrails.org/active_support_core_extensions.html#stand-alone-active-support

Please sign in to comment.