aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r--activemodel/test/cases/validations/i18n_generate_message_validation_test.rb8
-rw-r--r--activemodel/test/cases/validations/i18n_validation_test.rb13
-rw-r--r--activemodel/test/cases/validations_test.rb6
3 files changed, 7 insertions, 20 deletions
diff --git a/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb b/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb
index 37bba5e95e..07e4341289 100644
--- a/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb
+++ b/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb
@@ -5,7 +5,7 @@ require 'models/person'
class I18nGenerateMessageValidationTest < Test::Unit::TestCase
def setup
- reset_callbacks Person
+ Person.reset_callbacks(:validate)
@person = Person.new
@old_load_path, @old_backend = I18n.load_path, I18n.backend
@@ -45,12 +45,6 @@ class I18nGenerateMessageValidationTest < Test::Unit::TestCase
I18n.backend = @old_backend
end
- def reset_callbacks(*models)
- models.each do |model|
- model.instance_variable_set("@validate_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
- end
- end
-
# validates_inclusion_of: generate_message(attr_name, :inclusion, :default => configuration[:message], :value => value)
def test_generate_message_inclusion_with_default_message
assert_equal 'is not included in the list', @person.errors.generate_message(:title, :inclusion, :default => nil, :value => 'title')
diff --git a/activemodel/test/cases/validations/i18n_validation_test.rb b/activemodel/test/cases/validations/i18n_validation_test.rb
index 544b680b4b..fc4f1926b0 100644
--- a/activemodel/test/cases/validations/i18n_validation_test.rb
+++ b/activemodel/test/cases/validations/i18n_validation_test.rb
@@ -7,8 +7,7 @@ class I18nValidationTest < ActiveModel::TestCase
include ActiveModel::TestsDatabase
def setup
- reset_callbacks Person
-
+ Person.reset_callbacks(:validate)
@person = Person.new
@old_load_path, @old_backend = I18n.load_path, I18n.backend
@@ -18,17 +17,11 @@ class I18nValidationTest < ActiveModel::TestCase
end
def teardown
- reset_callbacks Person
+ Person.reset_callbacks(:validate)
I18n.load_path.replace @old_load_path
I18n.backend = @old_backend
end
- def reset_callbacks(*models)
- models.each do |model|
- model.instance_variable_set("@validate_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
- end
- end
-
def test_percent_s_interpolation_syntax_in_error_messages_was_deprecated
assert_not_deprecated do
default = "%s interpolation syntax was deprecated"
@@ -532,4 +525,4 @@ class I18nValidationTest < ActiveModel::TestCase
assert_equal ["I am a custom error"], @person.errors[:title]
end
-end \ No newline at end of file
+end
diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb
index 0b340e68bf..d44667e722 100644
--- a/activemodel/test/cases/validations_test.rb
+++ b/activemodel/test/cases/validations_test.rb
@@ -121,8 +121,8 @@ class ValidationsTest < ActiveModel::TestCase
end
def test_invalid_validator
- Topic.validate 3
- assert_raise(ArgumentError) { t = Topic.create }
+ Topic.validate :i_dont_exist
+ assert_raise(NameError) { t = Topic.create }
end
def test_errors_to_xml
@@ -189,4 +189,4 @@ class ValidationsTest < ActiveModel::TestCase
all_errors = t.errors.to_a
assert_deprecated { assert_equal all_errors, t.errors.each_full{|err| err} }
end
-end \ No newline at end of file
+end