Allow collection input to accept a collection of symbols, closes #33

This commit is contained in:
Carlos Antonio da Silva 2010-08-07 17:11:21 -03:00
parent 7626fa42df
commit cf997937e1
2 changed files with 8 additions and 1 deletions

View File

@ -46,7 +46,7 @@ module SimpleForm
label, value = :first, :last
when Integer
label, value = :to_s, :to_i
when String, NilClass
when String, Symbol, NilClass
label, value = :to_s, :to_s
end

View File

@ -327,6 +327,13 @@ class InputTest < ActionView::TestCase
assert_select 'label.collection_radio', 'CARLOS'
end
test 'input should allow symbols for collections' do
with_input_for @user, :name, :select, :collection => [:jose, :carlos]
assert_select 'select.select#user_name'
assert_select 'select option[value=jose]', 'jose'
assert_select 'select option[value=carlos]', 'carlos'
end
# With no object
test 'input should be generated properly when object is not present' do
with_input_for :project, :name, :string