Add failing test to label with single wrapper.

The :label_html options is being propagate to the label wrapper
This commit is contained in:
Rafael Mendonça França 2012-06-26 23:22:25 -03:00
parent 3d9a2ec19c
commit 9237674f73
2 changed files with 17 additions and 0 deletions

View File

@ -210,6 +210,14 @@ class FormBuilderTest < ActionView::TestCase
end
end
test 'builder should not propagate label options to wrapper with custom wrapper' do
swap_wrapper :default, self.custom_wrapper_with_wrapped_label do
with_form_for @user, :name, :label_html => { :class => 'my_label' }
assert_no_select 'form div.label.my_label'
assert_select 'form label.my_label.string'
end
end
test 'builder should generate a input with label' do
with_form_for @user, :name
assert_select 'form label.string[for=user_name]', /Name/

View File

@ -55,6 +55,15 @@ module MiscHelpers
end
end
def custom_wrapper_with_wrapped_label
SimpleForm.build :tag => :div, :class => "custom_wrapper" do |b|
b.wrapper :tag => :div, :class => 'elem' do |component|
component.use :label, :wrap_with => { :tag => :div, :class => 'label' }
component.use :input
end
end
end
def custom_wrapper_without_top_level
SimpleForm.build :tag => false, :class => 'custom_wrapper_without_top_level' do |b|
b.use :label_input