mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove :confirm and :disable_with options for ActionView::Helpers::UrlHelper#link_to and #button_to were deprecated.
This commit is contained in:
parent
6c2cbc6fff
commit
8b80d72327
2 changed files with 0 additions and 93 deletions
|
@ -548,28 +548,10 @@ module ActionView
|
||||||
html_options = html_options.stringify_keys
|
html_options = html_options.stringify_keys
|
||||||
html_options['data-remote'] = 'true' if link_to_remote_options?(options) || link_to_remote_options?(html_options)
|
html_options['data-remote'] = 'true' if link_to_remote_options?(options) || link_to_remote_options?(html_options)
|
||||||
|
|
||||||
disable_with = html_options.delete("disable_with")
|
|
||||||
confirm = html_options.delete('confirm')
|
|
||||||
method = html_options.delete('method')
|
method = html_options.delete('method')
|
||||||
|
|
||||||
if confirm
|
|
||||||
message = ":confirm option is deprecated and will be removed from Rails 4.1. " \
|
|
||||||
"Use 'data: { confirm: \'Text\' }' instead."
|
|
||||||
ActiveSupport::Deprecation.warn message
|
|
||||||
|
|
||||||
html_options["data-confirm"] = confirm
|
|
||||||
end
|
|
||||||
|
|
||||||
add_method_to_attributes!(html_options, method) if method
|
add_method_to_attributes!(html_options, method) if method
|
||||||
|
|
||||||
if disable_with
|
|
||||||
message = ":disable_with option is deprecated and will be removed from Rails 4.1. " \
|
|
||||||
"Use 'data: { disable_with: \'Text\' }' instead."
|
|
||||||
ActiveSupport::Deprecation.warn message
|
|
||||||
|
|
||||||
html_options["data-disable-with"] = disable_with
|
|
||||||
end
|
|
||||||
|
|
||||||
html_options
|
html_options
|
||||||
else
|
else
|
||||||
link_to_remote_options?(options) ? {'data-remote' => 'true'} : {}
|
link_to_remote_options?(options) ? {'data-remote' => 'true'} : {}
|
||||||
|
|
|
@ -93,15 +93,6 @@ class UrlHelperTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_button_to_with_deprecated_confirm
|
|
||||||
assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.1. Use 'data: { confirm: \'Text\' }' instead" do
|
|
||||||
assert_dom_equal(
|
|
||||||
%{<form method="post" action="http://www.example.com" class="button_to"><div><input data-confirm="Are you sure?" type="submit" value="Hello" /></div></form>},
|
|
||||||
button_to("Hello", "http://www.example.com", confirm: "Are you sure?")
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_button_to_with_javascript_disable_with
|
def test_button_to_with_javascript_disable_with
|
||||||
assert_dom_equal(
|
assert_dom_equal(
|
||||||
%{<form method="post" action="http://www.example.com" class="button_to"><div><input data-disable-with="Greeting..." type="submit" value="Hello" /></div></form>},
|
%{<form method="post" action="http://www.example.com" class="button_to"><div><input data-disable-with="Greeting..." type="submit" value="Hello" /></div></form>},
|
||||||
|
@ -109,15 +100,6 @@ class UrlHelperTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_button_to_with_javascript_deprecated_disable_with
|
|
||||||
assert_deprecated ":disable_with option is deprecated and will be removed from Rails 4.1. Use 'data: { disable_with: \'Text\' }' instead" do
|
|
||||||
assert_dom_equal(
|
|
||||||
%{<form method="post" action="http://www.example.com" class="button_to"><div><input data-disable-with="Greeting..." type="submit" value="Hello" /></div></form>},
|
|
||||||
button_to("Hello", "http://www.example.com", disable_with: "Greeting...")
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_button_to_with_remote_and_form_options
|
def test_button_to_with_remote_and_form_options
|
||||||
assert_dom_equal(
|
assert_dom_equal(
|
||||||
%{<form method="post" action="http://www.example.com" class="custom-class" data-remote="true" data-type="json"><div><input type="submit" value="Hello" /></div></form>},
|
%{<form method="post" action="http://www.example.com" class="custom-class" data-remote="true" data-type="json"><div><input type="submit" value="Hello" /></div></form>},
|
||||||
|
@ -132,15 +114,6 @@ class UrlHelperTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_button_to_with_remote_and_javascript_with_deprecated_confirm
|
|
||||||
assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.1. Use 'data: { confirm: \'Text\' }' instead" do
|
|
||||||
assert_dom_equal(
|
|
||||||
%{<form method="post" action="http://www.example.com" class="button_to" data-remote="true"><div><input data-confirm="Are you sure?" type="submit" value="Hello" /></div></form>},
|
|
||||||
button_to("Hello", "http://www.example.com", remote: true, confirm: "Are you sure?")
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_button_to_with_remote_and_javascript_disable_with
|
def test_button_to_with_remote_and_javascript_disable_with
|
||||||
assert_dom_equal(
|
assert_dom_equal(
|
||||||
%{<form method="post" action="http://www.example.com" class="button_to" data-remote="true"><div><input data-disable-with="Greeting..." type="submit" value="Hello" /></div></form>},
|
%{<form method="post" action="http://www.example.com" class="button_to" data-remote="true"><div><input data-disable-with="Greeting..." type="submit" value="Hello" /></div></form>},
|
||||||
|
@ -148,15 +121,6 @@ class UrlHelperTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_button_to_with_remote_and_javascript_deprecated_disable_with
|
|
||||||
assert_deprecated ":disable_with option is deprecated and will be removed from Rails 4.1. Use 'data: { disable_with: \'Text\' }' instead" do
|
|
||||||
assert_dom_equal(
|
|
||||||
%{<form method="post" action="http://www.example.com" class="button_to" data-remote="true"><div><input data-disable-with="Greeting..." type="submit" value="Hello" /></div></form>},
|
|
||||||
button_to("Hello", "http://www.example.com", remote: true, disable_with: "Greeting...")
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_button_to_with_remote_false
|
def test_button_to_with_remote_false
|
||||||
assert_dom_equal(
|
assert_dom_equal(
|
||||||
%{<form method="post" action="http://www.example.com" class="button_to"><div><input type="submit" value="Hello" /></div></form>},
|
%{<form method="post" action="http://www.example.com" class="button_to"><div><input type="submit" value="Hello" /></div></form>},
|
||||||
|
@ -265,27 +229,6 @@ class UrlHelperTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_link_tag_with_deprecated_confirm
|
|
||||||
assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.1. Use 'data: { confirm: \'Text\' }' instead" do
|
|
||||||
assert_dom_equal(
|
|
||||||
%{<a href="http://www.example.com" data-confirm="Are you sure?">Hello</a>},
|
|
||||||
link_to("Hello", "http://www.example.com", confirm: "Are you sure?")
|
|
||||||
)
|
|
||||||
end
|
|
||||||
assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.1. Use 'data: { confirm: \'Text\' }' instead" do
|
|
||||||
assert_dom_equal(
|
|
||||||
%{<a href="http://www.example.com" data-confirm="You cant possibly be sure, can you?">Hello</a>},
|
|
||||||
link_to("Hello", "http://www.example.com", confirm: "You cant possibly be sure, can you?")
|
|
||||||
)
|
|
||||||
end
|
|
||||||
assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.1. Use 'data: { confirm: \'Text\' }' instead" do
|
|
||||||
assert_dom_equal(
|
|
||||||
%{<a href="http://www.example.com" data-confirm="You cant possibly be sure,\n can you?">Hello</a>},
|
|
||||||
link_to("Hello", "http://www.example.com", confirm: "You cant possibly be sure,\n can you?")
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_link_to_with_remote
|
def test_link_to_with_remote
|
||||||
assert_dom_equal(
|
assert_dom_equal(
|
||||||
%{<a href="http://www.example.com" data-remote="true">Hello</a>},
|
%{<a href="http://www.example.com" data-remote="true">Hello</a>},
|
||||||
|
@ -349,15 +292,6 @@ class UrlHelperTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_link_tag_using_post_javascript_and_with_deprecated_confirm
|
|
||||||
assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.1. Use 'data: { confirm: \'Text\' }' instead" do
|
|
||||||
assert_dom_equal(
|
|
||||||
%{<a href="http://www.example.com" data-method="post" rel="nofollow" data-confirm="Are you serious?">Hello</a>},
|
|
||||||
link_to("Hello", "http://www.example.com", method: :post, confirm: "Are you serious?")
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_link_tag_using_delete_javascript_and_href_and_confirm
|
def test_link_tag_using_delete_javascript_and_href_and_confirm
|
||||||
assert_dom_equal(
|
assert_dom_equal(
|
||||||
%{<a href="\#" rel="nofollow" data-confirm="Are you serious?" data-method="delete">Destroy</a>},
|
%{<a href="\#" rel="nofollow" data-confirm="Are you serious?" data-method="delete">Destroy</a>},
|
||||||
|
@ -365,15 +299,6 @@ class UrlHelperTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_link_tag_using_delete_javascript_and_href_and_with_deprecated_confirm
|
|
||||||
assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.1. Use 'data: { confirm: \'Text\' }' instead" do
|
|
||||||
assert_dom_equal(
|
|
||||||
%{<a href="\#" rel="nofollow" data-confirm="Are you serious?" data-method="delete">Destroy</a>},
|
|
||||||
link_to("Destroy", "http://www.example.com", method: :delete, href: '#', confirm: "Are you serious?")
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_link_tag_with_block
|
def test_link_tag_with_block
|
||||||
assert_dom_equal %{<a href="/"><span>Example site</span></a>},
|
assert_dom_equal %{<a href="/"><span>Example site</span></a>},
|
||||||
link_to('/') { content_tag(:span, 'Example site') }
|
link_to('/') { content_tag(:span, 'Example site') }
|
||||||
|
|
Loading…
Reference in a new issue