From 1b2a4b043dcfd4e5b5cd644c35e98f056a85860f Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 26 Jan 2012 15:44:13 -0200 Subject: [PATCH] Fix nested style check for options hash --- lib/simple_form/inputs/boolean_input.rb | 2 +- test/inputs/boolean_input_test.rb | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/simple_form/inputs/boolean_input.rb b/lib/simple_form/inputs/boolean_input.rb index c9891ac4..4f4e0787 100644 --- a/lib/simple_form/inputs/boolean_input.rb +++ b/lib/simple_form/inputs/boolean_input.rb @@ -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 diff --git a/test/inputs/boolean_input_test.rb b/test/inputs/boolean_input_test.rb index 394ad9ed..498efdcc 100644 --- a/test/inputs/boolean_input_test.rb +++ b/test/inputs/boolean_input_test.rb @@ -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