Merge pull request #7058 from frodsan/fix_as_random_tests

Fix tests that depend on run order
This commit is contained in:
Rafael Mendonça França 2012-08-24 08:56:16 -07:00
commit 2c571b3f05
6 changed files with 34 additions and 23 deletions

@ -493,14 +493,18 @@ def stub_queue(klass, queue)
end end
test "assets tags should use a Mailer's asset_host settings when available" do test "assets tags should use a Mailer's asset_host settings when available" do
ActionMailer::Base.config.asset_host = "global.com" begin
ActionMailer::Base.config.assets_dir = "global/" 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 end
# Before and After hooks # Before and After hooks

@ -11,7 +11,6 @@ def process_removed_attributes(klass, attrs)
end end
class MassAssignmentSecurityTest < ActiveModel::TestCase class MassAssignmentSecurityTest < ActiveModel::TestCase
def test_attribute_protection def test_attribute_protection
user = User.new user = User.new
expected = { "name" => "John Smith", "email" => "john@smith.com" } expected = { "name" => "John Smith", "email" => "john@smith.com" }
@ -96,7 +95,6 @@ def test_mass_assignment_protection_inheritance
assert_blank TightDescendant.protected_attributes(:admin) - TightDescendant.attributes_protected_by_default assert_blank TightDescendant.protected_attributes(:admin) - TightDescendant.attributes_protected_by_default
assert_equal Set.new(['name', 'address', 'admin', 'super_powers']), TightDescendant.accessible_attributes(:admin) assert_equal Set.new(['name', 'address', 'admin', 'super_powers']), TightDescendant.accessible_attributes(:admin)
end end
def test_mass_assignment_multiparameter_protector def test_mass_assignment_multiparameter_protector
@ -107,14 +105,14 @@ def test_mass_assignment_multiparameter_protector
end end
def test_custom_sanitizer def test_custom_sanitizer
old_sanitizer = User._mass_assignment_sanitizer
user = User.new user = User.new
User.mass_assignment_sanitizer = CustomSanitizer.new User.mass_assignment_sanitizer = CustomSanitizer.new
assert_raise StandardError do assert_raise StandardError do
user.sanitize_for_mass_assignment("admin" => true) user.sanitize_for_mass_assignment("admin" => true)
end end
ensure ensure
User.mass_assignment_sanitizer = nil User.mass_assignment_sanitizer = old_sanitizer
end end
end
end

@ -1,3 +1,3 @@
class ClassFolder::ClassFolderSubclass < ClassFolder class ClassFolder::ClassFolderSubclass < ClassFolder
ConstantInClassFolder ConstantInClassFolder = 'indeed'
end end

@ -67,17 +67,24 @@ class QualifiedConstTest < ActiveSupport::TestCase
end end
test "qualified_const_set" do test "qualified_const_set" do
m = Module.new begin
assert_equal m, Object.qualified_const_set("QualifiedConstTestMod2", m) m = Module.new
assert_equal m, ::QualifiedConstTestMod2 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. # We are going to assign to existing constants on purpose, so silence warnings.
silence_warnings do silence_warnings do
assert_equal true, QualifiedConstTestMod.qualified_const_set("QualifiedConstTestMod::X", true) assert_equal true, QualifiedConstTestMod.qualified_const_set("QualifiedConstTestMod::X", true)
assert_equal true, QualifiedConstTestMod::X assert_equal true, QualifiedConstTestMod::X
assert_equal 10, QualifiedConstTestMod::M.qualified_const_set("X", 10) assert_equal 10, QualifiedConstTestMod::M.qualified_const_set("X", 10)
assert_equal 10, QualifiedConstTestMod::M::X 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
end end

@ -679,6 +679,8 @@ def test_unloadable_should_return_change_flag
assert_equal true, M.unloadable assert_equal true, M.unloadable
assert_equal false, M.unloadable assert_equal false, M.unloadable
end end
ensure
Object.class_eval { remove_const :M }
end end
def test_unloadable_constants_should_receive_callback def test_unloadable_constants_should_receive_callback

@ -169,11 +169,11 @@ def test_acronyms_camelize_lower
def test_underscore_acronym_sequence def test_underscore_acronym_sequence
ActiveSupport::Inflector.inflections do |inflect| ActiveSupport::Inflector.inflections do |inflect|
inflect.acronym("API") inflect.acronym("API")
inflect.acronym("HTML5") inflect.acronym("JSON")
inflect.acronym("HTML") inflect.acronym("HTML")
end end
assert_equal("html5_html_api", ActiveSupport::Inflector.underscore("HTML5HTMLAPI")) assert_equal("json_html_api", ActiveSupport::Inflector.underscore("JSONHTMLAPI"))
end end
def test_underscore def test_underscore