aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-12-21 01:39:18 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-12-21 01:39:18 +0900
commit8034dde023a64b98c6b3edb80a44e4cc23f8979f (patch)
tree38ad756d57390a272bceb7068c19ad1e25587689 /activemodel/test
parent3da358ea83b86368021d6f289627d0682d24d30b (diff)
downloadrails-8034dde023a64b98c6b3edb80a44e4cc23f8979f.tar.gz
rails-8034dde023a64b98c6b3edb80a44e4cc23f8979f.tar.bz2
rails-8034dde023a64b98c6b3edb80a44e4cc23f8979f.zip
Module#{define_method,alias_method,undef_method,remove_method} become public since Ruby 2.5
https://bugs.ruby-lang.org/issues/14133
Diffstat (limited to 'activemodel/test')
-rw-r--r--activemodel/test/cases/validations/length_validation_test.rb2
-rw-r--r--activemodel/test/cases/validations/numericality_validation_test.rb10
2 files changed, 6 insertions, 6 deletions
diff --git a/activemodel/test/cases/validations/length_validation_test.rb b/activemodel/test/cases/validations/length_validation_test.rb
index 774a2cde74..37e10f783c 100644
--- a/activemodel/test/cases/validations/length_validation_test.rb
+++ b/activemodel/test/cases/validations/length_validation_test.rb
@@ -427,7 +427,7 @@ class LengthValidationTest < ActiveModel::TestCase
end
def test_validates_length_of_using_proc_as_maximum_with_model_method
- Topic.send(:define_method, :max_title_length, lambda { 5 })
+ Topic.define_method(:max_title_length) { 5 }
Topic.validates_length_of :title, maximum: Proc.new(&:max_title_length)
t = Topic.new("title" => "valid", "content" => "whatever")
diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb
index ca22e38c2d..eb4b02df93 100644
--- a/activemodel/test/cases/validations/numericality_validation_test.rb
+++ b/activemodel/test/cases/validations/numericality_validation_test.rb
@@ -66,7 +66,7 @@ class NumericalityValidationTest < ActiveModel::TestCase
end
def test_validates_numericality_of_with_integer_only_and_proc_as_value
- Topic.send(:define_method, :allow_only_integers?, lambda { false })
+ Topic.define_method(:allow_only_integers?) { false }
Topic.validates_numericality_of :approved, only_integer: Proc.new(&:allow_only_integers?)
invalid!(NIL + BLANK + JUNK)
@@ -214,23 +214,23 @@ class NumericalityValidationTest < ActiveModel::TestCase
end
def test_validates_numericality_with_proc
- Topic.send(:define_method, :min_approved, lambda { 5 })
+ Topic.define_method(:min_approved) { 5 }
Topic.validates_numericality_of :approved, greater_than_or_equal_to: Proc.new(&:min_approved)
invalid!([3, 4])
valid!([5, 6])
ensure
- Topic.send(:remove_method, :min_approved)
+ Topic.remove_method :min_approved
end
def test_validates_numericality_with_symbol
- Topic.send(:define_method, :max_approved, lambda { 5 })
+ Topic.define_method(:max_approved) { 5 }
Topic.validates_numericality_of :approved, less_than_or_equal_to: :max_approved
invalid!([6])
valid!([4, 5])
ensure
- Topic.send(:remove_method, :max_approved)
+ Topic.remove_method :max_approved
end
def test_validates_numericality_with_numeric_message