Rename checkbox_style to boolean_style to make it more generic

This commit is contained in:
Carlos Antonio da Silva 2012-01-26 15:06:33 -02:00
parent ed43005eb3
commit a6c5d8f1d6
4 changed files with 10 additions and 10 deletions

View File

@ -121,7 +121,7 @@ SimpleForm.setup do |config|
# Define the way to render checkboxes with labels. Defaults to :inline.
# :inline => input + label
# :nested => label > input
# config.checkbox_style = :inline
# config.boolean_style = :inline
# You can define the class to use on all forms. Default is simple_form.
# config.form_class = :simple_form

View File

@ -64,8 +64,8 @@ module SimpleForm
# Define the way to render checkboxes with labels. Defaults to :inline.
# :inline => input + label
# :nested => label > input
mattr_accessor :checkbox_style
@@checkbox_style = :inline
mattr_accessor :boolean_style
@@boolean_style = :inline
# You can define the class to use on all forms. Default is simple_form.
mattr_accessor :form_class

View File

@ -18,7 +18,7 @@ module SimpleForm
private
def nested_style?
options[:checkbox_style] || SimpleForm.checkbox_style == :nested
options[:boolean_style] || SimpleForm.boolean_style == :nested
end
# Booleans are not required by default because in most of the cases

View File

@ -14,28 +14,28 @@ class BooleanInputTest < ActionView::TestCase
assert_no_select 'label'
end
test 'input uses inline checkbox style by default' do
test 'input uses inline boolean style by default' do
with_input_for @user, :active, :boolean
assert_select 'input.boolean + label.boolean.optional'
assert_no_select 'label > input'
end
test 'input allows changing default checkbox style config to nested, generating a default label' do
swap SimpleForm, :checkbox_style => :nested do
test 'input allows changing default boolean style config to nested, generating a default label' do
swap SimpleForm, :boolean_style => :nested do
with_input_for @user, :active, :boolean
assert_select 'label > input.boolean'
assert_no_select 'label.boolean'
end
end
test 'input accepts changing checkbox style through given options' do
with_input_for @user, :active, :boolean, :checkbox_style => :nested
test 'input accepts changing boolean style 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 with nested style allows disabling label' do
swap SimpleForm, :checkbox_style => :nested do
swap SimpleForm, :boolean_style => :nested do
with_input_for @user, :active, :boolean, :label => false
assert_select 'input.boolean'
assert_no_select 'label'