aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorThomas Fuchs <thomas@fesch.at>2007-06-03 14:27:43 +0000
committerThomas Fuchs <thomas@fesch.at>2007-06-03 14:27:43 +0000
commit3cfb894bac2f25f2160189e4909ae7756927d8ad (patch)
tree4cd2be3584a79cf0232e8d2011d38d6e13456205 /actionpack/test
parent13058b018861053be8bf5dbec4cafe51b89e173f (diff)
downloadrails-3cfb894bac2f25f2160189e4909ae7756927d8ad.tar.gz
rails-3cfb894bac2f25f2160189e4909ae7756927d8ad.tar.bz2
rails-3cfb894bac2f25f2160189e4909ae7756927d8ad.zip
Allow JSON-style values for the :with option of observe_field. Closes #8557 [kommen]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6930 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/prototype_helper_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb
index 033e75de78..b669d20b22 100644
--- a/actionpack/test/template/prototype_helper_test.rb
+++ b/actionpack/test/template/prototype_helper_test.rb
@@ -174,6 +174,17 @@ class PrototypeHelperTest < Test::Unit::TestCase
observe_field("glass", :frequency => 5.minutes, :url => { :action => "reorder_if_empty" })
end
+ def test_observe_field_using_with_option
+ expected = %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/check_value', {asynchronous:true, evalScripts:true, parameters:'id=' + value})})\n//]]>\n</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=' + value")
+ end
+
+ def test_observe_field_using_json_in_with_option
+ expected = %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/check_value', {asynchronous:true, evalScripts:true, parameters:{'id':value}})})\n//]]>\n</script>)
+ assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => "{'id':value}")
+ end
+
def test_observe_field_using_function_for_callback
assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {alert('Element changed')})\n//]]>\n</script>),
observe_field("glass", :frequency => 5.minutes, :function => "alert('Element changed')")