diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-12-26 23:00:31 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-12-26 23:00:31 -0300 |
commit | ceedec7edcadbad824f58e84bc2c1eddbe8539ce (patch) | |
tree | 4f74cf1de3be2a90102c4b116cc1b6a46e1c9c52 /actionpack | |
parent | b05819fd28acd069556767a99738a6fd8b0a1965 (diff) | |
download | rails-ceedec7edcadbad824f58e84bc2c1eddbe8539ce.tar.gz rails-ceedec7edcadbad824f58e84bc2c1eddbe8539ce.tar.bz2 rails-ceedec7edcadbad824f58e84bc2c1eddbe8539ce.zip |
Fix collection_radio_buttons with the option `:checked` with value of
`false`
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/helpers/tags/collection_helpers.rb | 3 | ||||
-rw-r--r-- | actionpack/test/template/form_collections_helper_test.rb | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/tags/collection_helpers.rb b/actionpack/lib/action_view/helpers/tags/collection_helpers.rb index 4e33e79a36..e92a318c73 100644 --- a/actionpack/lib/action_view/helpers/tags/collection_helpers.rb +++ b/actionpack/lib/action_view/helpers/tags/collection_helpers.rb @@ -44,7 +44,8 @@ module ActionView html_options = @html_options.dup [:checked, :selected, :disabled].each do |option| - next unless current_value = @options[option] + current_value = @options[option] + next if current_value.nil? accept = if current_value.respond_to?(:call) current_value.call(item) diff --git a/actionpack/test/template/form_collections_helper_test.rb b/actionpack/test/template/form_collections_helper_test.rb index c73e80ed88..2131f81396 100644 --- a/actionpack/test/template/form_collections_helper_test.rb +++ b/actionpack/test/template/form_collections_helper_test.rb @@ -149,6 +149,12 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_select 'label[for=post_category_id_2]', 'Category 2' end + test 'collection radio accepts checked item which has a value of false' do + with_collection_radio_buttons :user, :active, [[1, true], [0, false]], :last, :first, :checked => false + assert_no_select 'input[type=radio][value=true][checked=checked]' + assert_select 'input[type=radio][value=false][checked=checked]' + end + # COLLECTION CHECK BOXES test 'collection check boxes accepts a collection and generate a serie of checkboxes for value method' do collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] |