diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-20 22:02:22 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-20 22:02:22 +0000 |
commit | a61360688cd0e1f43f523866384d0d0796a4ea73 (patch) | |
tree | dfa09275f2165b1af8363642b67d85b5702cf793 /actionpack/test/template/asset_tag_helper_test.rb | |
parent | ee8d110068e958b400987b5f224e14e292fd0558 (diff) | |
download | rails-a61360688cd0e1f43f523866384d0d0796a4ea73.tar.gz rails-a61360688cd0e1f43f523866384d0d0796a4ea73.tar.bz2 rails-a61360688cd0e1f43f523866384d0d0796a4ea73.zip |
Changed .htaccess to allow dispatch.* to be called from a sub-directory as part of the push with Action Pack to make Rails work on non-vhost setups #826 [Nicholas Seckar/Tobias Luetke] Fixed routing and helpers to make Rails work on non-vhost setups #826 [Nicholas Seckar/Tobias Luetke]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@945 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/template/asset_tag_helper_test.rb')
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 87 |
1 files changed, 84 insertions, 3 deletions
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 896d843165..d51d0075b0 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -8,11 +8,19 @@ class AssetTagHelperTest < Test::Unit::TestCase def setup @controller = Class.new do + def url_for(options, *parameters_for_method_reference) "http://www.example.com" end - end - @controller = @controller.new + + end.new + + @request = Class.new do + def relative_url_root + "" + end + end.new + end AutoDiscoveryToTag = { @@ -31,6 +39,74 @@ class AssetTagHelperTest < Test::Unit::TestCase %(stylesheet_link_tag("random.styles", "/css/stylish")) => %(<link href="/stylesheets/random.styles" media="screen" rel="Stylesheet" type="text/css" />\n<link href="/css/stylish.css" media="screen" rel="Stylesheet" type="text/css" />) } + ImageLinkToTag = { + %(image_tag("xml")) => %(<img alt="Xml" src="/images/xml.png" />), + %(image_tag("rss", :alt => "rss syndication")) => %(<img alt="rss syndication" src="/images/rss.png" />), + %(image_tag("gold", :size => "45x70")) => %(<img alt="Gold" height="70" src="/images/gold.png" width="45" />), + } + + def test_auto_discovery + AutoDiscoveryToTag.each { |method, tag| assert_equal(tag, eval(method)) } + end + + def test_javascript_include + JavascriptIncludeToTag.each { |method, tag| assert_equal(tag, eval(method)) } + end + + def test_style_link + StyleLinkToTag.each { |method, tag| assert_equal(tag, eval(method)) } + end + + def test_image_tag + ImageLinkToTag.each { |method, tag| assert_equal(tag, eval(method)) } + end + +end + +class AssetTagHelperNonVhostTest < Test::Unit::TestCase + include ActionView::Helpers::TagHelper + include ActionView::Helpers::UrlHelper + include ActionView::Helpers::AssetTagHelper + + def setup + @controller = Class.new do + + def url_for(options, *parameters_for_method_reference) + "http://www.example.com/calloboration/hieraki" + end + + end.new + + @request = Class.new do + def relative_url_root + "/calloboration/hieraki" + end + end.new + + end + + AutoDiscoveryToTag = { + %(auto_discovery_link_tag(:rss, :action => "feed")) => %(<link href="http://www.example.com/calloboration/hieraki" rel="alternate" title="RSS" type="application/rss+xml" />), + %(auto_discovery_link_tag(:atom)) => %(<link href="http://www.example.com/calloboration/hieraki" rel="alternate" title="ATOM" type="application/atom+xml" />), + %(auto_discovery_link_tag) => %(<link href="http://www.example.com/calloboration/hieraki" rel="alternate" title="RSS" type="application/rss+xml" />), + } + + JavascriptIncludeToTag = { + %(javascript_include_tag("xmlhr")) => %(<script language="JavaScript" src="/calloboration/hieraki/javascripts/xmlhr.js" type="text/javascript"></script>), + %(javascript_include_tag("common.javascript", "/elsewhere/cools")) => %(<script language="JavaScript" src="/calloboration/hieraki/javascripts/common.javascript" type="text/javascript"></script>\n<script language="JavaScript" src="/calloboration/hieraki/elsewhere/cools.js" type="text/javascript"></script>), + } + + StyleLinkToTag = { + %(stylesheet_link_tag("style")) => %(<link href="/calloboration/hieraki/stylesheets/style.css" media="screen" rel="Stylesheet" type="text/css" />), + %(stylesheet_link_tag("random.styles", "/css/stylish")) => %(<link href="/calloboration/hieraki/stylesheets/random.styles" media="screen" rel="Stylesheet" type="text/css" />\n<link href="/calloboration/hieraki/css/stylish.css" media="screen" rel="Stylesheet" type="text/css" />) + } + + ImageLinkToTag = { + %(image_tag("xml")) => %(<img alt="Xml" src="/calloboration/hieraki/images/xml.png" />), + %(image_tag("rss", :alt => "rss syndication")) => %(<img alt="rss syndication" src="/calloboration/hieraki/images/rss.png" />), + %(image_tag("gold", :size => "45x70")) => %(<img alt="Gold" height="70" src="/calloboration/hieraki/images/gold.png" width="45" />), + } + def test_auto_discovery AutoDiscoveryToTag.each { |method, tag| assert_equal(tag, eval(method)) } end @@ -44,6 +120,11 @@ class AssetTagHelperTest < Test::Unit::TestCase end def test_image_tag - assert_equal %(<img alt="Gold" height="70" src="/images/gold.png" width="45" />), image_tag("gold", :size => "45x70") + assert_equal %(<img alt="Gold" height="70" src="/calloboration/hieraki/images/gold.png" width="45" />), image_tag("gold", :size => "45x70") + end + + def test_image_tag + ImageLinkToTag.each { |method, tag| assert_equal(tag, eval(method)) } end + end
\ No newline at end of file |