Add tests to ensure false booleans are checked/selected correctly with collection helpers

This commit is contained in:
Carlos Antonio da Silva 2011-02-14 23:44:22 -02:00
parent cb26688ca6
commit 1f2ba59d3d
1 changed files with 14 additions and 0 deletions

View File

@ -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"]'