mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Allow :remote => false to be passed to link_to
And add tests for `button_to` and `form_tag` which currently behave as expected, so we avoid a regression. Signed-off-by: wycats <wycats@gmail.com>
This commit is contained in:
parent
a8330c2006
commit
d5d717161d
3 changed files with 21 additions and 3 deletions
|
@ -596,10 +596,8 @@ module ActionView
|
|||
html_options = {} if html_options.nil?
|
||||
html_options = html_options.stringify_keys
|
||||
|
||||
if (options.is_a?(Hash) && options.key?('remote')) || (html_options.is_a?(Hash) && html_options.key?('remote'))
|
||||
if (options.is_a?(Hash) && options.key?('remote') && options.delete('remote')) || (html_options.is_a?(Hash) && html_options.key?('remote') && html_options.delete('remote'))
|
||||
html_options['data-remote'] = 'true'
|
||||
options.delete('remote') if options.is_a?(Hash)
|
||||
html_options.delete('remote') if html_options.is_a?(Hash)
|
||||
end
|
||||
|
||||
confirm = html_options.delete("confirm")
|
||||
|
|
|
@ -62,6 +62,12 @@ class FormTagHelperTest < ActionView::TestCase
|
|||
assert_dom_equal expected, actual
|
||||
end
|
||||
|
||||
def test_form_tag_with_remote_false
|
||||
actual = form_tag({}, :remote => false)
|
||||
expected = %(<form action="http://www.example.com" method="post">)
|
||||
assert_dom_equal expected, actual
|
||||
end
|
||||
|
||||
def test_form_tag_with_block_in_erb
|
||||
output_buffer = form_tag("http://example.com") { concat "Hello world!" }
|
||||
|
||||
|
|
|
@ -103,6 +103,13 @@ class UrlHelperTest < ActiveSupport::TestCase
|
|||
)
|
||||
end
|
||||
|
||||
def test_button_to_with_remote_false
|
||||
assert_dom_equal(
|
||||
"<form method=\"post\" action=\"http://www.example.com\" class=\"button_to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>",
|
||||
button_to("Hello", "http://www.example.com", :remote => false)
|
||||
)
|
||||
end
|
||||
|
||||
def test_button_to_enabled_disabled
|
||||
assert_dom_equal(
|
||||
"<form method=\"post\" action=\"http://www.example.com\" class=\"button_to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>",
|
||||
|
@ -205,6 +212,13 @@ class UrlHelperTest < ActiveSupport::TestCase
|
|||
)
|
||||
end
|
||||
|
||||
def test_link_to_with_remote_false
|
||||
assert_dom_equal(
|
||||
"<a href=\"http://www.example.com\">Hello</a>",
|
||||
link_to("Hello", "http://www.example.com", :remote => false)
|
||||
)
|
||||
end
|
||||
|
||||
def test_link_tag_using_post_javascript
|
||||
assert_dom_equal(
|
||||
"<a href='http://www.example.com' data-method=\"post\" rel=\"nofollow\">Hello</a>",
|
||||
|
|
Loading…
Reference in a new issue