提交 a1a41a39 编写于 作者: A Andrew Kaspick 提交者: wycats

remote_function patch with more detailed test

Signed-off-by: Nwycats <wycats@gmail.com>
上级 ef5ae60a
......@@ -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}"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册