Add "new inputs can override the default input_html_classes" test case

This commit is contained in:
Rigoberto Molina 2018-09-17 16:40:43 -07:00
parent 1411dc3349
commit 4b1cd65588
2 changed files with 15 additions and 0 deletions

View File

@ -109,6 +109,14 @@ class DiscoveryTest < ActionView::TestCase
end
end
test 'new inputs can override the default input_html_classes' do
discovery do
with_form_for @user, :avatar, as: :file
assert_select 'form input[type=file]#user_avatar.file.file-upload', false
assert_select 'form input[type=file]#user_avatar.file-upload'
end
end
test 'inputs method without wrapper_options are deprecated' do
discovery do
assert_deprecated do

View File

@ -37,6 +37,13 @@ class CollectionSelectInput < SimpleForm::Inputs::CollectionSelectInput
end
end
class FileInput < SimpleForm::Inputs::FileInput
def input_html_classes
super.delete_if { |html_class| html_class == 'file' }
super.push('file-upload')
end
end
module CustomInputs
class CustomizedInput < SimpleForm::Inputs::StringInput
def input_html_classes