add test for this case

This commit is contained in:
allomov 2012-10-05 19:45:20 +03:00
parent b96fedba88
commit 4aef53d5d2
2 changed files with 12 additions and 0 deletions

View File

@ -237,6 +237,11 @@ class FormBuilderTest < ActionView::TestCase
assert_no_select 'form label'
end
test 'builder should be able to disable the label for an input and return a html safe string' do
with_form_for @validating_user, :age, :label => false, :wrapper => custom_wrapper_with_wrapped_label_input
assert_select 'form input[type=text]'
end
test 'builder should use custom label' do
with_form_for @user, :name, :label => 'Yay!'
assert_select 'form label', /Yay!/

View File

@ -84,6 +84,13 @@ module MiscHelpers
end
end
def custom_wrapper_with_wrapped_label_input
SimpleForm.build :tag => :section, :class => "custom_wrapper", :pattern => false do |b|
b.use :label_input, :wrap_with => { :tag => :div, :class => :field }
end
end
def custom_form_for(object, *args, &block)
simple_form_for(object, *(args << { :builder => CustomFormBuilder }), &block)
end