1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00

don't get maxlength from validation when tokenizer present

This commit is contained in:
Vasiliy Ermolovich 2012-01-02 23:48:41 +03:00
parent 81ac8fa9b2
commit e50011eadf
3 changed files with 7 additions and 1 deletions

View file

@ -11,7 +11,7 @@ module SimpleForm
def maximum_length_from_validation
if options[:maxlength] == true
if length_validator = find_length_validator
if (length_validator = find_length_validator) && !length_validator.options[:tokenizer]
length_validator.options[:maximum]
end
else

View file

@ -47,6 +47,11 @@ class StringInputTest < ActionView::TestCase
assert_select 'input.string[maxlength=25]'
end
test 'input should not get maxlength from validation when tokenizer present' do
with_input_for @validating_user, :action, :string
assert_no_select 'input.string[maxlength]'
end
test 'input should not generate placeholder by default' do
with_input_for @user, :name, :string
assert_no_select 'input[placeholder]'

View file

@ -155,6 +155,7 @@ class ValidatingUser < User
:only_integer => true
validates_length_of :name, :maximum => 25
validates_length_of :description, :maximum => 50
validates_length_of :action, :maximum => 10, :tokenizer => lambda { |str| str.scan(/\w+/) }
def min_amount
10