Skip to content

Commit

Permalink
add failing test for issue when input_html options apply to wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
nashby authored and rafaelfranca committed Jun 27, 2012
1 parent 4891aaa commit 3d9a2ec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/form_builder/general_test.rb
Expand Up @@ -202,6 +202,14 @@ def with_custom_form_for(object, *args, &block)
assert_select 'form input#my_input.my_input.string'
end

test 'builder should not propagate input options to wrapper with custom wrapper' do
swap_wrapper :default, self.custom_wrapper_with_wrapped_input do
with_form_for @user, :name, :input_html => { :class => 'my_input' }
assert_no_select 'form div.input.my_input'
assert_select 'form input.my_input.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/
Expand Down
9 changes: 9 additions & 0 deletions test/support/misc_helpers.rb
Expand Up @@ -46,6 +46,15 @@ def custom_wrapper
end
end

def custom_wrapper_with_wrapped_input
SimpleForm.build :tag => :div, :class => "custom_wrapper" do |b|
b.wrapper :tag => :div, :class => 'elem' do |component|
component.use :label
component.use :input, :wrap_with => { :tag => :div, :class => '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
Expand Down

0 comments on commit 3d9a2ec

Please sign in to comment.