aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-03-29 16:34:01 -0600
committerSean Griffin <sean@thoughtbot.com>2015-03-29 16:34:01 -0600
commit1c341eb7cbaeb52435f14c2595e391bfb2e5e38b (patch)
tree27f1969f7cabfd36cc6ab18fbb03f8c37913d8ed /activemodel/test
parent01421d5b6259fae07c799d90b58b2258eaa243c9 (diff)
downloadrails-1c341eb7cbaeb52435f14c2595e391bfb2e5e38b.tar.gz
rails-1c341eb7cbaeb52435f14c2595e391bfb2e5e38b.tar.bz2
rails-1c341eb7cbaeb52435f14c2595e391bfb2e5e38b.zip
Deprecate the `:tokenizer` option to `validates_length_of`
As demonstrated by #19570, this option is severely limited, and satisfies an extremely specific use case. Realistically, there's not much reason for this option to exist. Its functionality can be trivially replicated with a normal Ruby method. Let's deprecate this option, in favor of the simpler solution.
Diffstat (limited to 'activemodel/test')
-rw-r--r--activemodel/test/cases/validations/length_validation_test.rb20
1 files changed, 16 insertions, 4 deletions
diff --git a/activemodel/test/cases/validations/length_validation_test.rb b/activemodel/test/cases/validations/length_validation_test.rb
index 209903898e..ee901b75fb 100644
--- a/activemodel/test/cases/validations/length_validation_test.rb
+++ b/activemodel/test/cases/validations/length_validation_test.rb
@@ -319,8 +319,14 @@ class LengthValidationTest < ActiveModel::TestCase
end
def test_validates_length_of_with_block
- Topic.validates_length_of :content, minimum: 5, too_short: "Your essay must be at least %{count} words.",
- tokenizer: lambda {|str| str.scan(/\w+/) }
+ assert_deprecated do
+ Topic.validates_length_of(
+ :content,
+ minimum: 5,
+ too_short: "Your essay must be at least %{count} words.",
+ tokenizer: lambda {|str| str.scan(/\w+/) },
+ )
+ end
t = Topic.new(content: "this content should be long enough")
assert t.valid?
@@ -332,8 +338,14 @@ class LengthValidationTest < ActiveModel::TestCase
def test_validates_length_of_with_symbol
- Topic.validates_length_of :content, minimum: 5, too_short: "Your essay must be at least %{count} words.",
- tokenizer: :my_word_tokenizer
+ assert_deprecated do
+ Topic.validates_length_of(
+ :content,
+ minimum: 5,
+ too_short: "Your essay must be at least %{count} words.",
+ tokenizer: :my_word_tokenizer,
+ )
+ end
t = Topic.new(content: "this content should be long enough")
assert t.valid?