Permalink
Browse files

remote_function patch with more detailed test

Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information...
1 parent ef5ae60 commit a1a41a3939318e9481469ea194660f3d8a9c1e66 @akaspick akaspick committed with wycats Jul 17, 2010
@@ -139,7 +139,7 @@ def remote_function(options)
function = "if (#{options[:condition]}) { #{function}; }" if options[:condition]
function = "if (confirm('#{escape_javascript(options[:confirm])}')) { #{function}; }" if options[:confirm]
- return function
+ return function.html_safe
end
# All the methods were moved to GeneratorMethods so that
@@ -104,6 +104,12 @@ def test_update_page_tag_with_html_options
assert_equal javascript_tag(create_generator(&block).to_s, {:defer => 'true'}), update_page_tag({:defer => 'true'}, &block)
end
+ def test_remote_function
+ res = remote_function(:url => authors_path, :with => "'author[name]='+$F('author_name')+'&author[dob]='+$F('author_dob')")
+ assert_equal "new Ajax.Request('/authors', {asynchronous:true, evalScripts:true, parameters:'author[name]='+$F('author_name')+'&author[dob]='+$F('author_dob')})", res
+ assert res.html_safe?
+ end
+
protected
def author_path(record)
"/authors/#{record.id}"

0 comments on commit a1a41a3

Please sign in to comment.