diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-10-08 03:30:29 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-10-08 03:30:29 +0000 |
commit | 074fe35b8a9c82e22a2c8b7559df158ad513981a (patch) | |
tree | eb480da4e854e6bfe071c2d6ea083cec3c1768bb /actionpack/test/template/url_helper_test.rb | |
parent | 85c86f09997fff1f07f5d58ecf69780d597e292c (diff) | |
download | rails-074fe35b8a9c82e22a2c8b7559df158ad513981a.tar.gz rails-074fe35b8a9c82e22a2c8b7559df158ad513981a.tar.bz2 rails-074fe35b8a9c82e22a2c8b7559df158ad513981a.zip |
Add link_to :back which uses your referrer with a fallback to a javascript link. #7366 [eventualbuddha, tarmo]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7791 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/template/url_helper_test.rb')
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index dc0186f9df..5c7abdfe56 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -1,6 +1,6 @@ require "#{File.dirname(__FILE__)}/../abstract_unit" -RequestMock = Struct.new("Request", :request_uri, :protocol, :host_with_port) +RequestMock = Struct.new("Request", :request_uri, :protocol, :host_with_port, :env) class UrlHelperTest < Test::Unit::TestCase include ActionView::Helpers::AssetTagHelper @@ -109,6 +109,16 @@ class UrlHelperTest < Test::Unit::TestCase assert_dom_equal "<a href=\"http://www.example.com?q1=v1&q2=v2\">http://www.example.com?q1=v1&q2=v2</a>", link_to(nil, "http://www.example.com?q1=v1&q2=v2") end + def test_link_tag_with_back + @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {'HTTP_REFERER' => 'http://www.example.com/referer'}) + assert_dom_equal "<a href=\"http://www.example.com/referer\">go back</a>", link_to('go back', :back) + end + + def test_link_tag_with_back_and_no_referer + @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {}) + assert_dom_equal "<a href=\"javascript:history.back()\">go back</a>", link_to('go back', :back) + end + def test_link_tag_with_img assert_dom_equal "<a href=\"http://www.example.com\"><img src='/favicon.jpg' /></a>", link_to("<img src='/favicon.jpg' />", "http://www.example.com") end |