Fix nested style check for options hash
This commit is contained in:
parent
fb796f0a85
commit
1b2a4b043d
|
@ -18,7 +18,7 @@ module SimpleForm
|
|||
private
|
||||
|
||||
def nested_style?
|
||||
options[:boolean_style] || SimpleForm.boolean_style == :nested
|
||||
options.fetch(:boolean_style, SimpleForm.boolean_style) == :nested
|
||||
end
|
||||
|
||||
# Booleans are not required by default because in most of the cases
|
||||
|
|
|
@ -28,12 +28,20 @@ class BooleanInputTest < ActionView::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
test 'input accepts changing boolean style through given options' do
|
||||
test 'input accepts changing boolean style to nested through given options' do
|
||||
with_input_for @user, :active, :boolean, :boolean_style => :nested
|
||||
assert_select 'label > input.boolean'
|
||||
assert_no_select 'label.boolean'
|
||||
end
|
||||
|
||||
test 'input accepts changing boolean style to inline through given options, when default is nested' do
|
||||
swap SimpleForm, :boolean_style => :nested do
|
||||
with_input_for @user, :active, :boolean, :boolean_style => :inline
|
||||
assert_select 'input.boolean + label.boolean'
|
||||
assert_no_select 'label > input'
|
||||
end
|
||||
end
|
||||
|
||||
test 'input with nested style allows disabling label' do
|
||||
swap SimpleForm, :boolean_style => :nested do
|
||||
with_input_for @user, :active, :boolean, :label => false
|
||||
|
|
Loading…
Reference in New Issue