Fix bug that disable the entire select and wrapper when option is a string or array. Closes #301

This commit is contained in:
George Guimarães 2011-08-30 21:31:48 -03:00
parent aca5fe06bf
commit d796f6a8d2
3 changed files with 18 additions and 1 deletions

View File

@ -11,6 +11,7 @@
* bug fix
* Fix bug when simple_fields_for is used with a hash like models and Rails 3.1
* Fix bug that doesn't remove the item_wrapper_tag or the collection_wrapper_tag on collection inputs when nil or false value is passed to these options (by gitbub.com/dw2)
* Fix bug that disable the entire select and wrapper when `disabled` option is a string or array
== 1.4.2

View File

@ -125,7 +125,7 @@ module SimpleForm
end
def disabled?
options[:disabled]
options[:disabled] === true
end
# Lookup translations for the given namespace using I18n, based on object name,

View File

@ -720,6 +720,22 @@ class InputTest < ActionView::TestCase
assert_select 'select option[value=2]', 'Carlos'
end
test 'input should disable the anothers components when the option is a object' do
with_input_for @user, :description, :select, :collection => ["Jose", "Carlos"], :disabled => true
assert_no_select 'select option[value=Jose][disabled=disabled]', 'Jose'
assert_no_select 'select option[value=Carlos][disabled=disabled]', 'Carlos'
assert_select 'select[disabled=disabled]'
assert_select 'div.disabled'
end
test 'input should not disable the anothers components when the option is a object' do
with_input_for @user, :description, :select, :collection => ["Jose", "Carlos"], :disabled => 'Jose'
assert_select 'select option[value=Jose][disabled=disabled]', 'Jose'
assert_no_select 'select option[value=Carlos][disabled=disabled]', 'Carlos'
assert_no_select 'select[disabled=disabled]'
assert_no_select 'div.disabled'
end
test 'input should allow overriding collection for radio types' do
with_input_for @user, :name, :radio, :collection => ['Jose', 'Carlos']
assert_select 'input[type=radio][value=Jose]'