New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bad placement output of button_to. #1367

Merged
merged 3 commits into from Jul 30, 2013
Jump to file or symbol
Failed to load files and symbols.
+47 −2
Diff settings

Always

Just for now

@@ -93,7 +93,9 @@ def form_tag(url, options={}, &block)
inner_form_html << csrf_token_field
end
inner_form_html << mark_safe(capture_html(&block))
concat_content content_tag(:form, inner_form_html, options)
not_concat = options.delete(:not_concat)
form_html = content_tag(:form, inner_form_html, options)
not_concat ? form_html : concat_content(form_html)
end
##
@@ -769,7 +771,7 @@ def button_to(*args, &block)
if block_given?
form_tag(url, options, &block)
else
form_tag(url, options) do
form_tag(url, options.merge!(:not_concat => true)) do
submit_tag(name)
end
end
@@ -0,0 +1,8 @@
<% button_to 'Foo button', '/foo', :class => 'foo-form' do %>
<% field_set_tag do %>
<%= hidden_field_tag :session_id, :value => "__secret__" %>
<%= label_tag :username %>
<% end %>
<% end %>
<%= content_tag(:p, 'button_to test', :id => 'test-point') %>
<%= button_to 'Bar button', '/bar' %>
@@ -0,0 +1,5 @@
- button_to 'Foo button', '/foo', :class => 'foo-form' do
- field_set_tag do
= label_tag :username
= content_tag(:p, 'button_to test', :id => 'test-point')
= button_to 'Bar button', '/bar'
@@ -0,0 +1,6 @@
= button_to 'Foo button', '/foo', :class => 'foo-form' do
= field_set_tag do
= hidden_field_tag :session_id, :value => "__secret__"
= label_tag :username
= content_tag(:p, 'button_to test', :id => 'test-point')
= button_to 'Bar button', '/bar'
@@ -960,6 +960,30 @@ def app
end
assert_has_tag('form button', :type => 'submit', :content => "My button's content", :title => "My button") { actual_html }
end
should 'display correct button_to in erb' do
visit '/erb/button_to'
assert_have_selector('form', :action => '/foo')
assert_have_selector('form label', :for => 'username', :content => 'Username: ')
assert_have_selector('form', :action => '/bar')
assert_have_selector('#test-point ~ form > input[type=submit]', :value => 'Bar button')
end
should 'display correct button_to in haml' do
visit '/haml/button_to'
assert_have_selector('form', :action => '/foo')
assert_have_selector('form label', :for => 'username', :content => 'Username: ')
assert_have_selector('form', :action => '/bar')
assert_have_selector('#test-point ~ form > input[type=submit]', :value => 'Bar button')
end
should 'display correct button_to in slim' do
visit '/slim/button_to'
assert_have_selector('form', :action => '/foo')
assert_have_selector('form label', :for => 'username', :content => 'Username: ')
assert_have_selector('form', :action => '/bar')
assert_have_selector('#test-point ~ form > input[type=submit]', :value => 'Bar button')
end
end
context 'for #range_field_tag' do
ProTip! Use n and p to navigate between commits in a pull request.