diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-02-13 12:09:36 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-02-13 12:09:36 -0200 |
commit | 7919c29d507b571315a6391fe56bf4f3bce23689 (patch) | |
tree | 205846ad837a1baacf5572a6fd25e035da1ee050 /activemodel/test/cases | |
parent | cc08de856acab3f480eb76b3e80cf2ea7705c9b6 (diff) | |
parent | c3fa5c3d25d9148d2806db577a2261032b341c34 (diff) | |
download | rails-7919c29d507b571315a6391fe56bf4f3bce23689.tar.gz rails-7919c29d507b571315a6391fe56bf4f3bce23689.tar.bz2 rails-7919c29d507b571315a6391fe56bf4f3bce23689.zip |
Merge pull request #16381 from kakipo/validate-length-tokenizer
Allow symbol as values for `tokenizer` of `LengthValidator`
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r-- | activemodel/test/cases/validations/length_validation_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/length_validation_test.rb b/activemodel/test/cases/validations/length_validation_test.rb index 29130ce46c..209903898e 100644 --- a/activemodel/test/cases/validations/length_validation_test.rb +++ b/activemodel/test/cases/validations/length_validation_test.rb @@ -330,6 +330,19 @@ class LengthValidationTest < ActiveModel::TestCase assert_equal ["Your essay must be at least 5 words."], t.errors[:content] end + + 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 + t = Topic.new(content: "this content should be long enough") + assert t.valid? + + t.content = "not long enough" + assert t.invalid? + assert t.errors[:content].any? + assert_equal ["Your essay must be at least 5 words."], t.errors[:content] + end + def test_validates_length_of_for_fixnum Topic.validates_length_of(:approved, is: 4) |