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

Add failing specs for required attaribute with wrapper.

This commit is contained in:
Jed Schneider 2015-05-03 20:02:09 +03:00 committed by Vasiliy Ermolovich
parent b407771548
commit 709f3e58c6
2 changed files with 18 additions and 0 deletions

View file

@ -110,4 +110,15 @@ class RequiredTest < ActionView::TestCase
assert_no_select 'input[required]'
assert_select 'input.optional#validating_user_phone_number'
end
test 'builder input does not generate required html attribute when option is set to false when it is set to true in wrapper' do
swap SimpleForm, browser_validations: true do
swap_wrapper :default, self.custom_wrapper_with_required_input do
with_concat_form_for(@user) do |f|
concat f.input :name, required: false
end
assert_no_select 'input[type=text][required]'
end
end
end
end

View file

@ -184,6 +184,13 @@ module MiscHelpers
end
end
def custom_wrapper_with_required_input
SimpleForm.build tag: :span, class: 'custom_wrapper' do |b|
b.use :html5
b.use :input, required: true
end
end
def custom_form_for(object, *args, &block)
simple_form_for(object, *args, { builder: CustomFormBuilder }, &block)
end