diff options
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/template/form_tag_helper_test.rb | 9 | ||||
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 27 |
2 files changed, 34 insertions, 2 deletions
diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 72edb047cf..9afa4a2927 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -375,7 +375,14 @@ class FormTagHelperTest < ActionView::TestCase def test_submit_tag assert_dom_equal( %(<input name='commit' data-disable-with="Saving..." onclick="alert('hello!')" type="submit" value="Save" />), - submit_tag("Save", 'data-disable-with' => "Saving...", :onclick => "alert('hello!')") + submit_tag("Save", :onclick => "alert('hello!')", :data => { :disable_with => "Saving..." }) + ) + end + + def test_submit_tag_with_no_onclick_options + assert_dom_equal( + %(<input name='commit' data-disable-with="Saving..." type="submit" value="Save" />), + submit_tag("Save", :data => { :disable_with => "Saving..." }) ) end diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 893197a115..cb6f378ecb 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -106,10 +106,19 @@ class UrlHelperTest < ActiveSupport::TestCase 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>", - button_to("Hello", "http://www.example.com", 'data-disable-with' => "Greeting...") + button_to("Hello", "http://www.example.com", :data => { :disable_with => "Greeting..." }) ) 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 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>", button_to("Hello", "http://www.example.com", :remote => true, :form => { :class => "custom-class", "data-type" => "json" } ) end @@ -130,6 +139,22 @@ class UrlHelperTest < ActiveSupport::TestCase end end + def test_button_to_with_remote_and_javascript_disable_with + 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, :data => { :disable_with => "Greeting..." }) + ) + 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 assert_dom_equal( "<form method=\"post\" action=\"http://www.example.com\" class=\"button_to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", |