class UrlHelperTest
Attributes
controller[RW]
In a few cases, the helper proxies to 'controller' or request.
In those cases, we'll set up a simple mock
request[RW]
In a few cases, the helper proxies to 'controller' or request.
In those cases, we'll set up a simple mock
Public Instance Methods
form_authenticity_token(*args)
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 689 def form_authenticity_token(*args) "secret" end
hash_for(options = {})
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 36 def hash_for(options = {}) { controller: "foo", action: "bar" }.merge!(options) end
Also aliased as: url_hash
protect_against_forgery?()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 685 def protect_against_forgery? request_forgery end
request_for_url(url, opts = {})
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 484 def request_for_url(url, opts = {}) env = Rack::MockRequest.env_for("http://www.example.com#{url}", opts) ActionDispatch::Request.new(env) end
request_forgery_protection_token()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 693 def request_forgery_protection_token "form_token" end
test_current_page_considering_params()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 508 def test_current_page_considering_params @request = request_for_url("/?order=desc&page=1") assert !current_page?(url_hash, check_parameters: true) assert !current_page?(url_hash.merge(check_parameters: true)) assert !current_page?(ActionController::Parameters.new(url_hash.merge(check_parameters: true)).permit!) assert !current_page?("http://www.example.com/", check_parameters: true) end
test_current_page_considering_params_when_options_does_not_respond_to_to_hash()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 517 def test_current_page_considering_params_when_options_does_not_respond_to_to_hash @request = request_for_url("/?order=desc&page=1") assert !current_page?(:back, check_parameters: false) end
test_current_page_ignoring_params()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 501 def test_current_page_ignoring_params @request = request_for_url("/?order=desc&page=1") assert current_page?(url_hash) assert current_page?("http://www.example.com/") end
test_current_page_with_double_escaped_params()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 550 def test_current_page_with_double_escaped_params @request = request_for_url("/category/administra%c3%a7%c3%a3o?callback_url=http%3a%2f%2fexample.com%2ffoo") assert current_page?(controller: "foo", action: "category", category: "administração", callback_url: "http://example.com/foo") end
test_current_page_with_escaped_params()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 536 def test_current_page_with_escaped_params @request = request_for_url("/category/administra%c3%a7%c3%a3o") assert current_page?(controller: "foo", action: "category", category: "administração") end
test_current_page_with_escaped_params_with_different_encoding()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 542 def test_current_page_with_escaped_params_with_different_encoding @request = request_for_url("/") @request.stub(:path, "/category/administra%c3%a7%c3%a3o".dup.force_encoding(Encoding::ASCII_8BIT)) do assert current_page?(controller: "foo", action: "category", category: "administração") assert current_page?("http://www.example.com/category/administra%c3%a7%c3%a3o") end end
test_current_page_with_http_head_method()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 489 def test_current_page_with_http_head_method @request = request_for_url("/", method: :head) assert current_page?(url_hash) assert current_page?("http://www.example.com/") end
test_current_page_with_not_get_verb()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 562 def test_current_page_with_not_get_verb @request = request_for_url("/events", method: :post) assert !current_page?("/events") end
test_current_page_with_params_that_match()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 523 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_scope_that_match()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 530 def test_current_page_with_scope_that_match @request = request_for_url("/engine/") assert current_page?("/engine") end
test_current_page_with_simple_url()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 495 def test_current_page_with_simple_url @request = request_for_url("/") assert current_page?(url_hash) assert current_page?("http://www.example.com/") end
test_current_page_with_trailing_slash()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 556 def test_current_page_with_trailing_slash @request = request_for_url("/posts") assert current_page?("/posts/") end
test_link_tag_does_not_escape_html_safe_content()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 447 def test_link_tag_does_not_escape_html_safe_content assert_dom_equal %{<a href="/">Malicious <script>content</script></a>}, link_to(raw("Malicious <script>content</script>"), "/") end
test_link_tag_escapes_content()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 442 def test_link_tag_escapes_content assert_dom_equal %{<a href="/">Malicious <script>content</script></a>}, link_to("Malicious <script>content</script>", "/") end
test_link_tag_using_block_and_hash()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 423 def test_link_tag_using_block_and_hash assert_dom_equal( %{<a href="/"><span>Example site</span></a>}, link_to(url_hash) { content_tag(:span, "Example site") } ) end
test_link_tag_using_block_in_erb()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 430 def test_link_tag_using_block_in_erb out = render_erb %{<%= link_to('/') do %>Example site<% end %>} assert_equal '<a href="/">Example site</a>', out end
test_link_tag_using_delete_javascript()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 378 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()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 385 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()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 406 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: "#", data: { confirm: "Are you serious?" }) ) end
test_link_tag_using_post_javascript()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 371 def test_link_tag_using_post_javascript assert_dom_equal( %{<a href="http://www.example.com" data-method="post" rel="nofollow">Hello</a>}, link_to("Hello", "http://www.example.com", method: :post) ) end
test_link_tag_using_post_javascript_and_confirm()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 399 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, data: { confirm: "Are you serious?" }) ) end
test_link_tag_using_post_javascript_and_rel()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 392 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()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 298 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 = %{<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()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 305 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 %{<a href="javascript:history.back()">go back</a>}, link end
test_link_tag_with_block()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 413 def test_link_tag_with_block assert_dom_equal %{<a href="/"><span>Example site</span></a>}, link_to("/") { content_tag(:span, "Example site") } end
test_link_tag_with_block_and_html_options()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 418 def test_link_tag_with_block_and_html_options assert_dom_equal %{<a class="special" href="/"><span>Example site</span></a>}, link_to("/", class: "special") { content_tag(:span, "Example site") } end
test_link_tag_with_custom_onclick()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 322 def test_link_tag_with_custom_onclick link = link_to("Hello", "http://www.example.com", onclick: "alert('yay!')") expected = %{<a href="http://www.example.com" onclick="alert('yay!')">Hello</a>} assert_dom_equal expected, link end
test_link_tag_with_host_option()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 282 def test_link_tag_with_host_option hash = hash_for(host: "www.example.com") expected = %{<a href="http://www.example.com/">Test Link</a>} assert_dom_equal(expected, link_to("Test Link", hash)) end
test_link_tag_with_html_safe_string()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 435 def test_link_tag_with_html_safe_string assert_dom_equal( %{<a href="/article/Gerd_M%C3%BCller">Gerd Müller</a>}, link_to("Gerd Müller", article_path("Gerd_Müller")) ) end
test_link_tag_with_img()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 311 def test_link_tag_with_img link = link_to(raw("<img src='/favicon.jpg' />"), "/") expected = %{<a href="/"><img src='/favicon.jpg' /></a>} assert_dom_equal expected, link end
test_link_tag_with_javascript_confirm()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 328 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", data: { 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", data: { 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", data: { confirm: "You cant possibly be sure,\n can you?" }) ) end
test_link_tag_with_query()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 288 def test_link_tag_with_query expected = %{<a href="http://www.example.com?q1=v1&q2=v2">Hello</a>} assert_dom_equal expected, link_to("Hello", "http://www.example.com?q1=v1&q2=v2") end
test_link_tag_with_query_and_no_name()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 293 def test_link_tag_with_query_and_no_name expected = %{<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()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 274 def test_link_tag_with_straight_url assert_dom_equal %{<a href="http://www.example.com">Hello</a>}, link_to("Hello", "http://www.example.com") end
test_link_tag_without_host_option()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 278 def test_link_tag_without_host_option assert_dom_equal(%{<a href="/">Test Link</a>}, link_to("Test Link", url_hash)) end
test_link_to_if()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 474 def test_link_to_if assert_equal "Showing", link_to_if(false, "Showing", url_hash) assert_dom_equal %{<a href="/">Listing</a>}, link_to_if(true, "Listing", url_hash) end
test_link_to_if_with_block()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 479 def test_link_to_if_with_block assert_equal "Fallback", link_to_if(false, "Showing", url_hash) { "Fallback" } assert_dom_equal %{<a href="/">Listing</a>}, link_to_if(true, "Listing", url_hash) { "Fallback" } end
test_link_to_unless()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 452 def test_link_to_unless assert_equal "Showing", link_to_unless(true, "Showing", url_hash) assert_dom_equal %{<a href="/">Listing</a>}, link_to_unless(false, "Listing", url_hash) assert_equal "<strong>Showing</strong>", link_to_unless(true, "Showing", url_hash) { |name| raw "<strong>#{name}</strong>" } assert_equal "test", link_to_unless(true, "Showing", url_hash) { "test" } assert_equal %{<b>Showing</b>}, link_to_unless(true, "<b>Showing</b>", url_hash) assert_equal %{<a href="/"><b>Showing</b></a>}, link_to_unless(false, "<b>Showing</b>", url_hash) assert_equal %{<b>Showing</b>}, link_to_unless(true, raw("<b>Showing</b>"), url_hash) assert_equal %{<a href="/"><b>Showing</b></a>}, link_to_unless(false, raw("<b>Showing</b>"), url_hash) end
test_link_to_unless_with_block()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 611 def test_link_to_unless_with_block assert_dom_equal %{<a href="/">Showing</a>}, link_to_unless(false, "Showing", url_hash) { "Fallback" } assert_equal "Fallback", link_to_unless(true, "Listing", url_hash) { "Fallback" } end
test_link_to_with_remote()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 343 def test_link_to_with_remote assert_dom_equal( %{<a href="http://www.example.com" data-remote="true">Hello</a>}, link_to("Hello", "http://www.example.com", remote: true) ) end
test_link_to_with_remote_false()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 350 def test_link_to_with_remote_false assert_dom_equal( %{<a href="http://www.example.com">Hello</a>}, link_to("Hello", "http://www.example.com", remote: false) ) end
test_link_to_with_string_remote_in_non_html_options()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 364 def test_link_to_with_string_remote_in_non_html_options assert_dom_equal( %{<a href="/" data-remote="true">Hello</a>}, link_to("Hello", hash_for("remote" => true), {}) ) end
test_link_to_with_symbolic_remote_in_non_html_options()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 357 def test_link_to_with_symbolic_remote_in_non_html_options assert_dom_equal( %{<a href="/" data-remote="true">Hello</a>}, link_to("Hello", hash_for(remote: true), {}) ) end
test_link_unless_current()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 568 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 %{<a href="/?order=asc">Showing</a>}, link_to_unless_current("Showing", hash_for(order: :asc)) assert_equal %{<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 %{<a href="/?order=desc&page=2\">Showing</a>}, link_to_unless_current("Showing", hash_for(order: "desc", page: 2)) assert_equal %{<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 %{<a href="/">Listing</a>}, link_to_unless_current("Listing", url_hash) assert_equal %{<a href="http://www.example.com/">Listing</a>}, link_to_unless_current("Listing", "http://www.example.com/") end
test_link_with_nil_html_options()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 317 def test_link_with_nil_html_options link = link_to("Hello", url_hash, nil) assert_dom_equal %{<a href="/">Hello</a>}, link end
test_mail_to()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 616 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_does_not_modify_html_options_hash()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 679 def test_mail_to_does_not_modify_html_options_hash options = { class: "special" } mail_to "me@example.com", "ME!", options assert_equal({ class: "special" }, options) end
test_mail_to_returns_html_safe_string()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 665 def test_mail_to_returns_html_safe_string assert mail_to("david@loudthinking.com").html_safe? end
test_mail_to_with_block()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 669 def test_mail_to_with_block assert_dom_equal %{<a href="mailto:me@example.com"><span>Email me</span></a>}, mail_to("me@example.com") { content_tag(:span, "Email me") } end
test_mail_to_with_block_and_options()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 674 def test_mail_to_with_block_and_options assert_dom_equal %{<a class="special" href="mailto:me@example.com?cc=ccaddress%40example.com"><span>Email me</span></a>}, mail_to("me@example.com", cc: "ccaddress@example.com", class: "special") { content_tag(:span, "Email me") } end
test_mail_to_with_html_safe_string()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 651 def test_mail_to_with_html_safe_string assert_dom_equal( %{<a href="mailto:david@loudthinking.com">david@loudthinking.com</a>}, mail_to(raw("david@loudthinking.com")) ) end
test_mail_to_with_img()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 646 def test_mail_to_with_img assert_dom_equal %{<a href="mailto:feedback@example.com"><img src="/feedback.png" /></a>}, mail_to("feedback@example.com", raw('<img src="/feedback.png" />')) end
test_mail_to_with_nil()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 658 def test_mail_to_with_nil assert_dom_equal( %{<a href="mailto:"></a>}, mail_to(nil) ) end
test_mail_to_with_special_characters()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 627 def test_mail_to_with_special_characters assert_dom_equal( %{<a href="mailto:%23%21%24%25%26%27%2A%2B-%2F%3D%3F%5E_%60%7B%7D%7C@example.org">#!$%&'*+-/=?^_`{}|@example.org</a>}, mail_to("#!$%&'*+-/=?^_`{}|@example.org") ) end
test_mail_with_options()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 634 def test_mail_with_options assert_dom_equal( %{<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&reply-to=foo%40bar.com">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.", reply_to: "foo@bar.com") ) assert_dom_equal( %{<a href="mailto:me@example.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: "", bcc: "", subject: "This is an example email", body: "This is the body of the message.") ) end
test_to_form_params_with_array_nested_in_hash()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 92 def test_to_form_params_with_array_nested_in_hash assert_equal( [{ name: "countries[]", value: "Denmark" }, { name: "countries[]", value: "Sweden" }], to_form_params(countries: ["Denmark", "Sweden"]) ) end
test_to_form_params_with_hash()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 78 def test_to_form_params_with_hash assert_equal( [{ name: :name, value: "David" }, { name: :nationality, value: "Danish" }], to_form_params(name: "David", nationality: "Danish") ) end
test_to_form_params_with_namespace()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 99 def test_to_form_params_with_namespace assert_equal( [{ name: "country[name]", value: "Denmark" }], to_form_params({ name: "Denmark" }, "country") ) end
test_to_form_params_with_nested_hash()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 85 def test_to_form_params_with_nested_hash assert_equal( [{ name: "country[name]", value: "Denmark" }], to_form_params(country: { name: "Denmark" }) ) end
test_url_for_does_not_escape_urls()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 41 def test_url_for_does_not_escape_urls assert_equal "/?a=b&c=d", url_for(hash_for(a: :b, c: :d)) end
test_url_for_does_not_include_empty_hashes()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 45 def test_url_for_does_not_include_empty_hashes assert_equal "/", url_for(hash_for(a: {})) end
test_url_for_with_back()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 49 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_javascript_referer()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 66 def test_url_for_with_back_and_javascript_referer referer = "javascript:alert(document.cookie)" @controller = Struct.new(:request).new(Struct.new(:env).new("HTTP_REFERER" => referer)) assert_equal "javascript:history.back()", url_for(:back) end
test_url_for_with_back_and_no_controller()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 61 def test_url_for_with_back_and_no_controller @controller = nil assert_equal "javascript:history.back()", url_for(:back) end
test_url_for_with_back_and_no_referer()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 56 def test_url_for_with_back_and_no_referer @controller = Struct.new(:request).new(Struct.new(:env).new({})) assert_equal "javascript:history.back()", url_for(:back) end
test_url_for_with_invalid_referer()
click to toggle source
# File actionview/test/template/url_helper_test.rb, line 72 def test_url_for_with_invalid_referer referer = "THIS IS NOT A URL" @controller = Struct.new(:request).new(Struct.new(:env).new("HTTP_REFERER" => referer)) assert_equal "javascript:history.back()", url_for(:back) end