Merge pull request #7058 from frodsan/fix_as_random_tests
Fix tests that depend on run order
This commit is contained in:
commit
2c571b3f05
@ -493,14 +493,18 @@ def stub_queue(klass, queue)
|
||||
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
|
||||
|
@ -11,7 +11,6 @@ def process_removed_attributes(klass, attrs)
|
||||
end
|
||||
|
||||
class MassAssignmentSecurityTest < ActiveModel::TestCase
|
||||
|
||||
def test_attribute_protection
|
||||
user = User.new
|
||||
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_equal Set.new(['name', 'address', 'admin', 'super_powers']), TightDescendant.accessible_attributes(:admin)
|
||||
|
||||
end
|
||||
|
||||
def test_mass_assignment_multiparameter_protector
|
||||
@ -107,14 +105,14 @@ def test_mass_assignment_multiparameter_protector
|
||||
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
|
@ -1,3 +1,3 @@
|
||||
class ClassFolder::ClassFolderSubclass < ClassFolder
|
||||
ConstantInClassFolder
|
||||
ConstantInClassFolder = 'indeed'
|
||||
end
|
||||
|
@ -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
|
||||
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
|
||||
# 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
|
||||
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
|
||||
|
||||
|
@ -679,6 +679,8 @@ def test_unloadable_should_return_change_flag
|
||||
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
|
||||
|
@ -169,11 +169,11 @@ def test_acronyms_camelize_lower
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user