From 1f2ba59d3d9b5c23316e9cf07ef63006d2eeb83c Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 14 Feb 2011 23:44:22 -0200 Subject: [PATCH] Add tests to ensure false booleans are checked/selected correctly with collection helpers --- test/inputs_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/inputs_test.rb b/test/inputs_test.rb index 6b90b4aa..baa4c6a7 100644 --- a/test/inputs_test.rb +++ b/test/inputs_test.rb @@ -463,6 +463,13 @@ class InputTest < ActionView::TestCase end end + test 'input should mark the checked value when using boolean and radios' do + @user.active = false + with_input_for @user, :active, :radio + assert_no_select 'input[type=radio][value=true][checked]' + assert_select 'input[type=radio][value=false][checked]' + end + test 'input should generate a boolean select with options by default for select types' do with_input_for @user, :active, :select assert_select 'select.select#user_active' @@ -497,6 +504,13 @@ class InputTest < ActionView::TestCase assert_select 'select option[selected=selected]', '18' end + test 'input should mark the selected value when using booleans and select' do + @user.active = false + with_input_for @user, :active, :select + assert_no_select 'select option[selected][value=true]', 'Yes' + assert_select 'select option[selected][value=false]', 'No' + end + test 'input should set the correct value when using a collection that includes floats' do with_input_for @user, :age, :select, :collection => [2.0, 2.5, 3.0, 3.5, 4.0, 4.5] assert_select 'select option[value="2.0"]'