diff options
author | Carlos Galdino <carloshsgaldino@gmail.com> | 2012-06-01 19:10:18 -0300 |
---|---|---|
committer | Carlos Galdino <carloshsgaldino@gmail.com> | 2012-06-05 15:34:30 -0300 |
commit | fc092a9cba5fceec38358072e50e09250cf58840 (patch) | |
tree | 7b4181b267ec8bfe0f07eee77c2f496d122cf5a3 /actionpack/test/template/form_tag_helper_test.rb | |
parent | 9f52d1526c816a35ec7bcc6e85f27b51d010dbae (diff) | |
download | rails-fc092a9cba5fceec38358072e50e09250cf58840.tar.gz rails-fc092a9cba5fceec38358072e50e09250cf58840.tar.bz2 rails-fc092a9cba5fceec38358072e50e09250cf58840.zip |
Deprecate `:confirm` in favor of `:data => { :confirm => 'Text' }` option
This deprecation applies to:
`button_to`
`button_tag`
`image_submit_tag`
`link_to`
`submit_tag`
As :confirm is an UI specific option is better to use the data attributes,
teaching users about unobtrusive JavaScript and how Rails works with it.
Diffstat (limited to 'actionpack/test/template/form_tag_helper_test.rb')
-rw-r--r-- | actionpack/test/template/form_tag_helper_test.rb | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index d9f91e952b..c0f300884a 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -385,9 +385,18 @@ class FormTagHelperTest < ActionView::TestCase end def test_submit_tag_with_confirmation + assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.0. 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_submit_tag_with_confirmation_without_deprecation_warning assert_dom_equal( %(<input name='commit' type='submit' value='Save' data-confirm="Are you sure?" />), - submit_tag("Save", :confirm => "Are you sure?") + submit_tag("Save", :data => { :confirm => "Are you sure?" }) ) end @@ -421,6 +430,22 @@ class FormTagHelperTest < ActionView::TestCase ) end + def test_button_tag_with_confirmation + assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.0. 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_button_tag_with_confirmation_without_deprecation_warning + assert_dom_equal( + %(<button name="button" type="submit" data-confirm="Are you sure?">Save</button>), + button_tag("Save", :type => "submit", :data => { :confirm => "Are you sure?" }) + ) + end + def test_button_tag_with_disable_with assert_deprecated ":disable_with option is deprecated and will be removed from Rails 4.0. Use 'data-disable-with' instead" do assert_dom_equal( @@ -461,9 +486,18 @@ class FormTagHelperTest < ActionView::TestCase end def test_image_submit_tag_with_confirmation + assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.0. 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_image_submit_tag_with_confirmation_without_deprecation_warning assert_dom_equal( %(<input type="image" src="/images/save.gif" data-confirm="Are you sure?" />), - image_submit_tag("save.gif", :confirm => "Are you sure?") + image_submit_tag("save.gif", :data => { :confirm => "Are you sure?" }) ) end |