Methods
- H
- P
- R
- T
-
- test_button_to_enabled_disabled,
- test_button_to_with_form_class,
- test_button_to_with_form_class_escapes,
- test_button_to_with_html_safe_URL,
- test_button_to_with_javascript_confirm,
- test_button_to_with_javascript_disable_with,
- test_button_to_with_method_delete,
- test_button_to_with_method_get,
- test_button_to_with_query,
- test_button_to_with_query_and_no_name,
- test_button_to_with_remote_and_form_options,
- test_button_to_with_remote_and_javascript_confirm,
- test_button_to_with_remote_and_javascript_confirm_and_javascript_disable_with,
- test_button_to_with_remote_and_javascript_disable_with,
- test_button_to_with_remote_false,
- test_button_to_with_straight_url,
- test_current_page_ignoring_params,
- test_current_page_with_not_get_verb,
- test_current_page_with_params_that_match,
- test_current_page_with_simple_url,
- test_link_tag_using_block_in_erb,
- test_link_tag_using_delete_javascript,
- test_link_tag_using_delete_javascript_and_href,
- test_link_tag_using_delete_javascript_and_href_and_confirm,
- test_link_tag_using_post_javascript,
- test_link_tag_using_post_javascript_and_confirm,
- test_link_tag_using_post_javascript_and_rel,
- test_link_tag_with_back,
- test_link_tag_with_back_and_no_referer,
- test_link_tag_with_custom_onclick,
- test_link_tag_with_host_option,
- test_link_tag_with_html_safe_string,
- test_link_tag_with_img,
- test_link_tag_with_javascript_confirm,
- test_link_tag_with_query,
- test_link_tag_with_query_and_no_name,
- test_link_tag_with_straight_url,
- test_link_tag_without_host_option,
- test_link_to_if,
- test_link_to_unless,
- test_link_to_with_remote,
- test_link_to_with_remote_false,
- test_link_to_with_symbolic_remote_in_non_html_options,
- test_link_unless_current,
- test_link_with_nil_html_options,
- test_mail_to,
- test_mail_to_returns_html_safe_string,
- test_mail_to_with_hex,
- test_mail_to_with_img,
- test_mail_to_with_javascript,
- test_mail_to_with_javascript_unicode,
- test_mail_to_with_replace_options,
- test_mail_with_options,
- test_url_for_does_not_escape_urls,
- test_url_for_with_back,
- test_url_for_with_back_and_no_referer
- U
Included Modules
- ActionView::Helpers::UrlHelper
- ActionView::Helpers::JavaScriptHelper
- ActionDispatch::Assertions::DomAssertions
- ActionView::Context
- RenderERBUtils
Attributes
| [RW] | controller | In a few cases, the helper proxies to 'controller' or request. In those cases, we'll set up a simple mock |
| [RW] | request | In a few cases, the helper proxies to 'controller' or request. In those cases, we'll set up a simple mock |
Instance Public methods
protect_against_forgery?()
Link
TODO: button_to looks at this … why?
request_for_url(url, opts = {})
Link
test_button_to_with_remote_and_javascript_confirm_and_javascript_disable_with()
Link
test_current_page_ignoring_params()
Link
test_current_page_with_not_get_verb()
Link
test_current_page_with_params_that_match()
Link
# File actionpack/test/template/url_helper_test.rb, line 339 def test_current_page_with_params_that_match @request = request_for_url("/?order=desc&page=1") assert current_page?(hash_for([:order, "desc", :page, "1"])) assert current_page?("http://www.example.com/?order=desc&page=1") end
test_current_page_with_simple_url()
Link
test_link_tag_using_block_in_erb()
Link
test_link_tag_using_delete_javascript()
Link
# File actionpack/test/template/url_helper_test.rb, line 243 def test_link_tag_using_delete_javascript assert_dom_equal( "<a href='http://www.example.com' rel=\"nofollow\" data-method=\"delete\">Destroy</a>", link_to("Destroy", "http://www.example.com", :method => :delete) ) end
test_link_tag_using_delete_javascript_and_href()
Link
# File actionpack/test/template/url_helper_test.rb, line 250 def test_link_tag_using_delete_javascript_and_href assert_dom_equal( "<a href='\#' rel=\"nofollow\" data-method=\"delete\">Destroy</a>", link_to("Destroy", "http://www.example.com", :method => :delete, :href => '#') ) end
test_link_tag_using_delete_javascript_and_href_and_confirm()
Link
# File actionpack/test/template/url_helper_test.rb, line 271 def test_link_tag_using_delete_javascript_and_href_and_confirm assert_dom_equal( "<a href='\#' rel=\"nofollow\" data-confirm=\"Are you serious?\" data-method=\"delete\">Destroy</a>", link_to("Destroy", "http://www.example.com", :method => :delete, :href => '#', :confirm => "Are you serious?"), "When specifying url, form should be generated with it, but not this.href" ) end
test_link_tag_using_post_javascript()
Link
test_link_tag_using_post_javascript_and_confirm()
Link
# File actionpack/test/template/url_helper_test.rb, line 264 def test_link_tag_using_post_javascript_and_confirm assert_dom_equal( "<a href=\"http://www.example.com\" data-method=\"post\" rel=\"nofollow\" data-confirm=\"Are you serious?\">Hello</a>", link_to("Hello", "http://www.example.com", :method => :post, :confirm => "Are you serious?") ) end
test_link_tag_using_post_javascript_and_rel()
Link
# File actionpack/test/template/url_helper_test.rb, line 257 def test_link_tag_using_post_javascript_and_rel assert_dom_equal( "<a href='http://www.example.com' data-method=\"post\" rel=\"example nofollow\">Hello</a>", link_to("Hello", "http://www.example.com", :method => :post, :rel => 'example') ) end
test_link_tag_with_back()
Link
# File actionpack/test/template/url_helper_test.rb, line 170 def test_link_tag_with_back env = {"HTTP_REFERER" => "http://www.example.com/referer"} @controller = Struct.new(:request).new(Struct.new(:env).new(env)) expected = %Q{<a href="#{env["HTTP_REFERER"]}">go back</a>} assert_dom_equal expected, link_to('go back', :back) end
test_link_tag_with_back_and_no_referer()
Link
# File actionpack/test/template/url_helper_test.rb, line 177 def test_link_tag_with_back_and_no_referer @controller = Struct.new(:request).new(Struct.new(:env).new({})) link = link_to('go back', :back) assert_dom_equal %Q{<a href="javascript:history.back()">go back</a>}, link end
test_link_tag_with_custom_onclick()
Link
# File actionpack/test/template/url_helper_test.rb, line 194 def test_link_tag_with_custom_onclick link = link_to("Hello", "http://www.example.com", :onclick => "alert('yay!')") expected = %Q{<a href="http://www.example.com" onclick="alert('yay!')">Hello</a>} assert_dom_equal expected, link end
test_link_tag_with_host_option()
Link
test_link_tag_with_html_safe_string()
Link
test_link_tag_with_img()
Link
test_link_tag_with_javascript_confirm()
Link
# File actionpack/test/template/url_helper_test.rb, line 200 def test_link_tag_with_javascript_confirm assert_dom_equal( "<a href=\"http://www.example.com\" data-confirm=\"Are you sure?\">Hello</a>", link_to("Hello", "http://www.example.com", :confirm => "Are you sure?") ) assert_dom_equal( "<a href=\"http://www.example.com\" data-confirm=\"You cant possibly be sure, can you?\">Hello</a>", link_to("Hello", "http://www.example.com", :confirm => "You cant possibly be sure, can you?") ) assert_dom_equal( "<a href=\"http://www.example.com\" data-confirm=\"You cant possibly be sure,\n can you?\">Hello</a>", link_to("Hello", "http://www.example.com", :confirm => "You cant possibly be sure,\n can you?") ) end
test_link_tag_with_query()
Link
test_link_tag_with_query_and_no_name()
Link
# File actionpack/test/template/url_helper_test.rb, line 165 def test_link_tag_with_query_and_no_name expected = %Q{<a href="http://www.example.com?q1=v1&q2=v2">http://www.example.com?q1=v1&q2=v2</a>} assert_dom_equal expected, link_to(nil, "http://www.example.com?q1=v1&q2=v2") end
test_link_tag_with_straight_url()
Link
test_link_tag_without_host_option()
Link
test_link_to_if()
Link
# File actionpack/test/template/url_helper_test.rb, line 315 def test_link_to_if assert_equal "Showing", link_to_if(false, "Showing", url_hash) assert_dom_equal %Q{<a href="/">Listing</a>}, link_to_if(true, "Listing", url_hash) assert_equal "Showing", link_to_if(false, "Showing", url_hash) end
test_link_to_unless()
Link
# File actionpack/test/template/url_helper_test.rb, line 291 def test_link_to_unless assert_equal "Showing", link_to_unless(true, "Showing", url_hash) assert_dom_equal %Q{<a href="/">Listing</a>}, link_to_unless(false, "Listing", url_hash) assert_equal "Showing", link_to_unless(true, "Showing", url_hash) assert_equal "<strong>Showing</strong>", link_to_unless(true, "Showing", url_hash) { |name| "<strong>#{name}</strong>".html_safe } assert_equal "test", link_to_unless(true, "Showing", url_hash) { "test" } assert_equal %Q{<b>Showing</b>}, link_to_unless(true, "<b>Showing</b>", url_hash) assert_equal %Q{<a href="/"><b>Showing</b></a>}, link_to_unless(false, "<b>Showing</b>", url_hash) assert_equal %Q{<b>Showing</b>}, link_to_unless(true, "<b>Showing</b>".html_safe, url_hash) assert_equal %Q{<a href="/"><b>Showing</b></a>}, link_to_unless(false, "<b>Showing</b>".html_safe, url_hash) end
test_link_to_with_remote()
Link
test_link_to_with_remote_false()
Link
test_link_to_with_symbolic_remote_in_non_html_options()
Link
test_link_unless_current()
Link
# File actionpack/test/template/url_helper_test.rb, line 352 def test_link_unless_current @request = request_for_url("/") assert_equal "Showing", link_to_unless_current("Showing", url_hash) assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/") @request = request_for_url("/?order=desc") assert_equal "Showing", link_to_unless_current("Showing", url_hash) assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/") @request = request_for_url("/?order=desc&page=1") assert_equal "Showing", link_to_unless_current("Showing", hash_for([:order, 'desc', :page, '1'])) assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/?order=desc&page=1") @request = request_for_url("/?order=desc") assert_equal %Q{<a href="/?order=asc">Showing</a>}, link_to_unless_current("Showing", hash_for([:order, :asc])) assert_equal %Q{<a href="http://www.example.com/?order=asc">Showing</a>}, link_to_unless_current("Showing", "http://www.example.com/?order=asc") @request = request_for_url("/?order=desc") assert_equal %Q{<a href="/?order=desc&page=2\">Showing</a>}, link_to_unless_current("Showing", hash_for([:order, "desc", :page, 2])) assert_equal %Q{<a href="http://www.example.com/?order=desc&page=2">Showing</a>}, link_to_unless_current("Showing", "http://www.example.com/?order=desc&page=2") @request = request_for_url("/show") assert_equal %Q{<a href="/">Listing</a>}, link_to_unless_current("Listing", url_hash) assert_equal %Q{<a href="http://www.example.com/">Listing</a>}, link_to_unless_current("Listing", "http://www.example.com/") end
test_link_with_nil_html_options()
Link
test_mail_to()
Link
# File actionpack/test/template/url_helper_test.rb, line 395 def test_mail_to assert_dom_equal "<a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>", mail_to("david@loudthinking.com") assert_dom_equal "<a href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>", mail_to("david@loudthinking.com", "David Heinemeier Hansson") assert_dom_equal( "<a class=\"admin\" href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>", mail_to("david@loudthinking.com", "David Heinemeier Hansson", "class" => "admin") ) assert_equal mail_to("david@loudthinking.com", "David Heinemeier Hansson", "class" => "admin"), mail_to("david@loudthinking.com", "David Heinemeier Hansson", :class => "admin") end
test_mail_to_returns_html_safe_string()
Link
# File actionpack/test/template/url_helper_test.rb, line 442 def test_mail_to_returns_html_safe_string assert mail_to("david@loudthinking.com").html_safe? assert mail_to("me@domain.com", "My email", :encode => "javascript").html_safe? assert mail_to("me@domain.com", "My email", :encode => "hex").html_safe? end
test_mail_to_with_hex()
Link
# File actionpack/test/template/url_helper_test.rb, line 428 def test_mail_to_with_hex assert_dom_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex") assert_dom_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">me@domain.com</a>", mail_to("me@domain.com", nil, :encode => "hex") end
test_mail_to_with_img()
Link
test_mail_to_with_javascript()
Link
# File actionpack/test/template/url_helper_test.rb, line 406 def test_mail_to_with_javascript snippet = mail_to("me@domain.com", "My email", :encode => "javascript") assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%5c%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%5c%22%3e%4d%79%20%65%6d%61%69%6c%3c%5c%2f%61%3e%27%29%3b'))</script>", snippet end
test_mail_to_with_javascript_unicode()
Link
# File actionpack/test/template/url_helper_test.rb, line 411 def test_mail_to_with_javascript_unicode snippet = mail_to("unicode@example.com", "únicode", :encode => "javascript") assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%5c%22%6d%61%69%6c%74%6f%3a%75%6e%69%63%6f%64%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%5c%22%3e%c3%ba%6e%69%63%6f%64%65%3c%5c%2f%61%3e%27%29%3b'))</script>", snippet end
test_mail_to_with_replace_options()
Link
# File actionpack/test/template/url_helper_test.rb, line 433 def test_mail_to_with_replace_options assert_dom_equal "<a href=\"mailto:wolfgang@stufenlos.net\">wolfgang(at)stufenlos(dot)net</a>", mail_to("wolfgang@stufenlos.net", nil, :replace_at => "(at)", :replace_dot => "(dot)") assert_dom_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">me(at)domain.com</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)") assert_dom_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex", :replace_at => "(at)") assert_dom_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">me(at)domain(dot)com</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)", :replace_dot => "(dot)") assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%5c%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%5c%22%3e%4d%79%20%65%6d%61%69%6c%3c%5c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript", :replace_at => "(at)", :replace_dot => "(dot)") assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%5c%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%5c%22%3e%6d%65%28%61%74%29%64%6f%6d%61%69%6e%28%64%6f%74%29%63%6f%6d%3c%5c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", nil, :encode => "javascript", :replace_at => "(at)", :replace_dot => "(dot)") end
test_mail_with_options()
Link
# File actionpack/test/template/url_helper_test.rb, line 416 def test_mail_with_options assert_dom_equal( %Q(<a href="mailto:me@example.com?cc=ccaddress%40example.com&bcc=bccaddress%40example.com&body=This%20is%20the%20body%20of%20the%20message.&subject=This%20is%20an%20example%20email">My email</a>), mail_to("me@example.com", "My email", :cc => "ccaddress@example.com", :bcc => "bccaddress@example.com", :subject => "This is an example email", :body => "This is the body of the message.") ) end
test_url_for_does_not_escape_urls()
Link
test_url_for_with_back()
Link
# File actionpack/test/template/url_helper_test.rb, line 39 def test_url_for_with_back referer = 'http://www.example.com/referer' @controller = Struct.new(:request).new(Struct.new(:env).new({"HTTP_REFERER" => referer})) assert_equal 'http://www.example.com/referer', url_for(:back) end
test_url_for_with_back_and_no_referer()
Link