aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/validations
diff options
context:
space:
mode:
authorZuhao Wan <wanzuhao@gmail.com>2014-03-10 21:22:22 +0800
committerZuhao Wan <wanzuhao@gmail.com>2014-03-11 00:48:25 +0800
commitcc6bc1cc46538d14ef65c14a5d0a2484d7b59977 (patch)
tree95ceac45014aee32eaa4746a27a29413208a0ae1 /activemodel/test/cases/validations
parent5ade4b05933aa986ff130d0f1f881a6d060db6be (diff)
downloadrails-cc6bc1cc46538d14ef65c14a5d0a2484d7b59977.tar.gz
rails-cc6bc1cc46538d14ef65c14a5d0a2484d7b59977.tar.bz2
rails-cc6bc1cc46538d14ef65c14a5d0a2484d7b59977.zip
Completely remove potential global state leaks in ActiveModel tests.
ActiveModel tests can now be run in random order.
Diffstat (limited to 'activemodel/test/cases/validations')
-rw-r--r--activemodel/test/cases/validations/confirmation_validation_test.rb18
-rw-r--r--activemodel/test/cases/validations/numericality_validation_test.rb2
2 files changed, 11 insertions, 9 deletions
diff --git a/activemodel/test/cases/validations/confirmation_validation_test.rb b/activemodel/test/cases/validations/confirmation_validation_test.rb
index 4c3d7a7615..65a2a1eb49 100644
--- a/activemodel/test/cases/validations/confirmation_validation_test.rb
+++ b/activemodel/test/cases/validations/confirmation_validation_test.rb
@@ -53,17 +53,17 @@ class ConfirmationValidationTest < ActiveModel::TestCase
end
def test_title_confirmation_with_i18n_attribute
- @old_load_path, @old_backend = I18n.load_path.dup, I18n.backend
- I18n.load_path.clear
- I18n.backend = I18n::Backend::Simple.new
- I18n.backend.store_translations('en', {
- errors: { messages: { confirmation: "doesn't match %{attribute}" } },
- activemodel: { attributes: { topic: { title: 'Test Title'} } }
- })
+ begin
+ @old_load_path, @old_backend = I18n.load_path.dup, I18n.backend
+ I18n.load_path.clear
+ I18n.backend = I18n::Backend::Simple.new
+ I18n.backend.store_translations('en', {
+ errors: { messages: { confirmation: "doesn't match %{attribute}" } },
+ activemodel: { attributes: { topic: { title: 'Test Title'} } }
+ })
- Topic.validates_confirmation_of(:title)
+ Topic.validates_confirmation_of(:title)
- begin
t = Topic.new("title" => "We should be confirmed","title_confirmation" => "")
assert t.invalid?
assert_equal ["doesn't match Test Title"], t.errors[:title_confirmation]
diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb
index f77cf47fb7..e1657407cf 100644
--- a/activemodel/test/cases/validations/numericality_validation_test.rb
+++ b/activemodel/test/cases/validations/numericality_validation_test.rb
@@ -119,6 +119,7 @@ class NumericalityValidationTest < ActiveModel::TestCase
invalid!([3, 4])
valid!([5, 6])
+ ensure
Topic.send(:remove_method, :min_approved)
end
@@ -128,6 +129,7 @@ class NumericalityValidationTest < ActiveModel::TestCase
invalid!([6])
valid!([4, 5])
+ ensure
Topic.send(:remove_method, :max_approved)
end