diff options
author | Erik St. Martin <alakriti@gmail.com> | 2010-01-24 14:32:55 -0500 |
---|---|---|
committer | Stefan Penner <stefan.penner@gmail.com> | 2010-01-27 12:44:34 -0600 |
commit | 06dd23d67133601f2639695a0fadab81213f6200 (patch) | |
tree | 03f6c2784bf5c87e0240b91df9c7743876d7b88c /actionpack/test/template/ajax_helper_test.rb | |
parent | d9af0dfac4c4935097671ff0d8b21876ff6c019a (diff) | |
download | rails-06dd23d67133601f2639695a0fadab81213f6200.tar.gz rails-06dd23d67133601f2639695a0fadab81213f6200.tar.bz2 rails-06dd23d67133601f2639695a0fadab81213f6200.zip |
removing Prototype inline js for attributes for :with and :condition, it now is free form js that can be placed there, also moved :submit out into AjaxHelper, updated tests to reflect changes
Diffstat (limited to 'actionpack/test/template/ajax_helper_test.rb')
-rw-r--r-- | actionpack/test/template/ajax_helper_test.rb | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/actionpack/test/template/ajax_helper_test.rb b/actionpack/test/template/ajax_helper_test.rb index 6fa8a95d42..c688b25f70 100644 --- a/actionpack/test/template/ajax_helper_test.rb +++ b/actionpack/test/template/ajax_helper_test.rb @@ -92,9 +92,18 @@ class AjaxHelperTest < AjaxHelperBaseTest end test "link_to_remote using :with expression" do - expected = %(<a href=\"#\" data-remote=\"true\" data-url=\"http://www.example.com/whatnot\" data-with=\"'id=' + encodeURIComponent(value)\">Remote outauthor</a>) - assert_dom_equal expected, link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :with => "id") - assert_dom_equal expected, link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :with => "'id=' + encodeURIComponent(value)") + expected = %(<a href=\"#\" data-remote=\"true\" data-url=\"http://www.example.com/whatnot\" data-with=\"id=123\">Remote outauthor</a>) + assert_dom_equal expected, link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :with => "id=123") + end + + test "link_to_remote using :condition expression" do + expected = %(<a href=\"#\" data-remote=\"true\" data-url=\"http://www.example.com/whatnot\" data-condition=\"$('foo').val() == true\">Remote outauthor</a>) + assert_dom_equal expected, link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :condition => '$(\'foo\').val() == true') + end + + test "link_to_remote using :submit" do + expected = %(<a href=\"#\" data-remote=\"true\" data-url=\"http://www.example.com/whatnot\" data-submit=\"myForm\">Remote outauthor</a>) + assert_dom_equal expected, link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :submit => 'myForm') end test "link_to_remote with method delete" do @@ -135,6 +144,11 @@ class AjaxHelperTest < AjaxHelperBaseTest button_to_remote("Remote outpost", { :url => { :action => "whatnot" }, :confirm => "Are you sure?"}, { :class => "fine" }) end + test "button_to_remote with :submit" do + assert_dom_equal %(<input class=\"fine\" type=\"button\" value=\"Remote outpost\" data-remote=\"true\" data-url=\"http://www.example.com/whatnot\" data-submit="myForm" />), + button_to_remote("Remote outpost", { :url => { :action => "whatnot" }, :submit => "myForm"}, { :class => "fine" }) + end + test "periodically_call_remote" do assert_dom_equal %(<script data-url=\"http://www.example.com/mehr_bier\" data-observe=\"true\" data-update-success=\"schremser_bier\" type=\"application/json\" data-periodical=\"true\"></script>), periodically_call_remote(:update => "schremser_bier", :url => { :action => "mehr_bier" }) @@ -258,9 +272,13 @@ class AjaxHelperTest < AjaxHelperBaseTest end test "observe_field using with option" do - expected = %(<script type=\"text/javascript\" data-observe=\"true\" data-observed=\"glass\" data-frequency=\"300\" type=\"application/json\" data-url=\"http://www.example.com/check_value\" data-with=\"'id=' + encodeURIComponent(value)\"></script>) - assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => 'id') - assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => "'id=' + encodeURIComponent(value)") + expected = %(<script type=\"text/javascript\" data-observe=\"true\" data-observed=\"glass\" data-frequency=\"300\" type=\"application/json\" data-url=\"http://www.example.com/check_value\" data-with=\"id=123\"></script>) + assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => 'id=123') + end + + test "observe_field using condition option" do + expected = %(<script type=\"text/javascript\" data-observe=\"true\" data-observed=\"glass\" data-frequency=\"300\" type=\"application/json\" data-url=\"http://www.example.com/check_value\" data-condition=\"$('foo').val() == true\"></script>) + assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :condition => '$(\'foo\').val() == true') end test "observe_field using json in with option" do |