diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-24 08:56:16 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-24 08:56:16 -0700 |
commit | 2c571b3f0544a6457db4818e752f4cd4bacd48b4 (patch) | |
tree | a7dae21847d456a9ac713c4b93de0546201a6100 | |
parent | 6a70f2dd6b791c3f4888122d5b7dd9c8f5cac871 (diff) | |
parent | 73f0afd1d41aa6c3febcc2e93e4d19d9bf0f27dc (diff) | |
download | rails-2c571b3f0544a6457db4818e752f4cd4bacd48b4.tar.gz rails-2c571b3f0544a6457db4818e752f4cd4bacd48b4.tar.bz2 rails-2c571b3f0544a6457db4818e752f4cd4bacd48b4.zip |
Merge pull request #7058 from frodsan/fix_as_random_tests
Fix tests that depend on run order
-rw-r--r-- | actionmailer/test/base_test.rb | 14 | ||||
-rw-r--r-- | activemodel/test/cases/mass_assignment_security_test.rb | 10 | ||||
-rw-r--r-- | activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/module/qualified_const_test.rb | 29 | ||||
-rw-r--r-- | activesupport/test/dependencies_test.rb | 2 | ||||
-rw-r--r-- | activesupport/test/inflector_test.rb | 4 |
6 files changed, 36 insertions, 25 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 4ed332d13d..fcf5be56f7 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -493,14 +493,18 @@ class BaseTest < ActiveSupport::TestCase end test "assets tags should use a Mailer's asset_host settings when available" do - ActionMailer::Base.config.asset_host = "global.com" - ActionMailer::Base.config.assets_dir = "global/" + begin + ActionMailer::Base.config.asset_host = "http://global.com" + ActionMailer::Base.config.assets_dir = "global/" - AssetMailer.asset_host = "http://local.com" + AssetMailer.asset_host = "http://local.com" - mail = AssetMailer.welcome + mail = AssetMailer.welcome - assert_equal(%{<img alt="Dummy" src="http://local.com/images/dummy.png" />}, mail.body.to_s.strip) + assert_equal(%{<img alt="Dummy" src="http://local.com/images/dummy.png" />}, mail.body.to_s.strip) + ensure + AssetMailer.asset_host = ActionMailer::Base.config.asset_host + end end # Before and After hooks diff --git a/activemodel/test/cases/mass_assignment_security_test.rb b/activemodel/test/cases/mass_assignment_security_test.rb index 0c6352cd71..45757615f5 100644 --- a/activemodel/test/cases/mass_assignment_security_test.rb +++ b/activemodel/test/cases/mass_assignment_security_test.rb @@ -11,7 +11,6 @@ class CustomSanitizer < ActiveModel::MassAssignmentSecurity::Sanitizer end class MassAssignmentSecurityTest < ActiveModel::TestCase - def test_attribute_protection user = User.new expected = { "name" => "John Smith", "email" => "john@smith.com" } @@ -96,7 +95,6 @@ class MassAssignmentSecurityTest < ActiveModel::TestCase assert_blank TightDescendant.protected_attributes(:admin) - TightDescendant.attributes_protected_by_default assert_equal Set.new(['name', 'address', 'admin', 'super_powers']), TightDescendant.accessible_attributes(:admin) - end def test_mass_assignment_multiparameter_protector @@ -107,14 +105,14 @@ class MassAssignmentSecurityTest < ActiveModel::TestCase end def test_custom_sanitizer + old_sanitizer = User._mass_assignment_sanitizer + user = User.new User.mass_assignment_sanitizer = CustomSanitizer.new assert_raise StandardError do user.sanitize_for_mass_assignment("admin" => true) end ensure - User.mass_assignment_sanitizer = nil - + User.mass_assignment_sanitizer = old_sanitizer end - -end +end
\ No newline at end of file diff --git a/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb b/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb index ef66ddaac7..402609c583 100644 --- a/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb +++ b/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb @@ -1,3 +1,3 @@ class ClassFolder::ClassFolderSubclass < ClassFolder - ConstantInClassFolder + ConstantInClassFolder = 'indeed' end diff --git a/activesupport/test/core_ext/module/qualified_const_test.rb b/activesupport/test/core_ext/module/qualified_const_test.rb index 8af0b9a023..343a848a42 100644 --- a/activesupport/test/core_ext/module/qualified_const_test.rb +++ b/activesupport/test/core_ext/module/qualified_const_test.rb @@ -67,17 +67,24 @@ class QualifiedConstTest < ActiveSupport::TestCase end test "qualified_const_set" do - m = Module.new - assert_equal m, Object.qualified_const_set("QualifiedConstTestMod2", m) - assert_equal m, ::QualifiedConstTestMod2 - - # We are going to assign to existing constants on purpose, so silence warnings. - silence_warnings do - assert_equal true, QualifiedConstTestMod.qualified_const_set("QualifiedConstTestMod::X", true) - assert_equal true, QualifiedConstTestMod::X - - assert_equal 10, QualifiedConstTestMod::M.qualified_const_set("X", 10) - assert_equal 10, QualifiedConstTestMod::M::X + begin + m = Module.new + assert_equal m, Object.qualified_const_set("QualifiedConstTestMod2", m) + assert_equal m, ::QualifiedConstTestMod2 + + # We are going to assign to existing constants on purpose, so silence warnings. + silence_warnings do + assert_equal true, QualifiedConstTestMod.qualified_const_set("QualifiedConstTestMod::X", true) + assert_equal true, QualifiedConstTestMod::X + + assert_equal 10, QualifiedConstTestMod::M.qualified_const_set("X", 10) + assert_equal 10, QualifiedConstTestMod::M::X + end + ensure + silence_warnings do + QualifiedConstTestMod.qualified_const_set('QualifiedConstTestMod::X', false) + QualifiedConstTestMod::M.qualified_const_set('X', 1) + end end end diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 69829bcda5..f1da6378a7 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -679,6 +679,8 @@ class DependenciesTest < ActiveSupport::TestCase assert_equal true, M.unloadable assert_equal false, M.unloadable end + ensure + Object.class_eval { remove_const :M } end def test_unloadable_constants_should_receive_callback diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb index cd91002147..aa41e57928 100644 --- a/activesupport/test/inflector_test.rb +++ b/activesupport/test/inflector_test.rb @@ -169,11 +169,11 @@ class InflectorTest < ActiveSupport::TestCase def test_underscore_acronym_sequence ActiveSupport::Inflector.inflections do |inflect| inflect.acronym("API") - inflect.acronym("HTML5") + inflect.acronym("JSON") inflect.acronym("HTML") end - assert_equal("html5_html_api", ActiveSupport::Inflector.underscore("HTML5HTMLAPI")) + assert_equal("json_html_api", ActiveSupport::Inflector.underscore("JSONHTMLAPI")) end def test_underscore |