diff options
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/form_tag_helper_test.rb | 28 | ||||
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 58 |
2 files changed, 86 insertions, 0 deletions
diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 05baaa5a85..72edb047cf 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -386,6 +386,15 @@ class FormTagHelperTest < ActionView::TestCase ) end + def test_submit_tag_with_deprecated_confirmation + assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.1. Use ':data => { :confirm => \'Text\' }' instead" do + assert_dom_equal( + %(<input name='commit' type='submit' value='Save' data-confirm="Are you sure?" />), + submit_tag("Save", :confirm => "Are you sure?") + ) + end + end + def test_button_tag assert_dom_equal( %(<button name="button" type="submit">Button</button>), @@ -444,6 +453,15 @@ class FormTagHelperTest < ActionView::TestCase ) end + def test_button_tag_with_deprecated_confirmation + assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.1. Use ':data => { :confirm => \'Text\' }' instead" do + assert_dom_equal( + %(<button name="button" type="submit" data-confirm="Are you sure?">Save</button>), + button_tag("Save", :type => "submit", :confirm => "Are you sure?") + ) + end + end + def test_image_submit_tag_with_confirmation assert_dom_equal( %(<input type="image" src="/images/save.gif" data-confirm="Are you sure?" />), @@ -451,6 +469,16 @@ class FormTagHelperTest < ActionView::TestCase ) end + def test_image_submit_tag_with_deprecated_confirmation + assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.1. Use ':data => { :confirm => \'Text\' }' instead" do + assert_dom_equal( + %(<input type="image" src="/images/save.gif" data-confirm="Are you sure?" />), + image_submit_tag("save.gif", :confirm => "Are you sure?") + ) + end + end + + def test_color_field_tag expected = %{<input id="car" name="car" type="color" />} assert_dom_equal(expected, color_field_tag("car")) diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index a09409635d..893197a115 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -94,6 +94,15 @@ class UrlHelperTest < ActiveSupport::TestCase ) 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 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>", @@ -112,6 +121,15 @@ class UrlHelperTest < ActiveSupport::TestCase ) 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_false assert_dom_equal( "<form method=\"post\" action=\"http://www.example.com\" class=\"button_to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", @@ -220,6 +238,27 @@ class UrlHelperTest < ActiveSupport::TestCase ) 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 can't possibly be sure, can you?\">Hello</a>", + link_to("Hello", "http://www.example.com", :confirm => "You can't 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 can't possibly be sure,\n can you?\">Hello</a>", + link_to("Hello", "http://www.example.com", :confirm => "You can't possibly be sure,\n can you?") + ) + end + end + def test_link_to_with_remote assert_dom_equal( "<a href=\"http://www.example.com\" data-remote=\"true\">Hello</a>", @@ -269,6 +308,15 @@ class UrlHelperTest < ActiveSupport::TestCase ) 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 assert_dom_equal( "<a href='\#' rel=\"nofollow\" data-confirm=\"Are you serious?\" data-method=\"delete\">Destroy</a>", @@ -277,6 +325,16 @@ class UrlHelperTest < ActiveSupport::TestCase ) 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?"), + "When specifying url, form should be generated with it, but not this.href" + ) + end + end + def test_link_tag_with_block assert_dom_equal '<a href="/"><span>Example site</span></a>', link_to('/') { content_tag(:span, 'Example site') } |