Add tests on :description hinted :string and :text

This commit is contained in:
Rob Biedenharn 2017-05-17 14:25:47 -04:00
parent b0e06fe174
commit fba2832897
1 changed files with 9 additions and 7 deletions

View File

@ -117,14 +117,10 @@ class FormBuilderTest < ActionView::TestCase
assert_select 'form input#user_name.string'
end
test 'builder generates text field for un-hinted text columns' do
test 'builder generates text areas for text columns' do
with_form_for @user, :description
if @user.respond_to?(:type_for_attribute) &&
@user.type_for_attribute('description').type == :string
assert_select 'form input#user_description.string'
else
assert_select 'form textarea#user_description.text'
end
assert_no_select 'form input#user_description.string'
assert_select 'form textarea#user_description.text'
end
test 'builder generates text areas for text columns when hinted' do
@ -133,6 +129,12 @@ class FormBuilderTest < ActionView::TestCase
assert_select 'form textarea#user_description.text'
end
test 'builder generates text field for text columns when hinted' do
with_form_for @user, :description, as: :string
assert_no_select 'form textarea#user_description.text'
assert_select 'form input#user_description.string'
end
test 'builder generates a checkbox for boolean columns' do
with_form_for @user, :active
assert_select 'form input[type=checkbox]#user_active.boolean'