diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-19 16:04:50 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-19 16:04:50 +0000 |
commit | 2a5fc27ceac142762dc66680364be17b100ab0b8 (patch) | |
tree | 2358154541295547ab1c48003a288dad209d8fdc /actionpack/test/template | |
parent | ad1fe7dd277e4e82bd8588e06c1181b6f8402683 (diff) | |
download | rails-2a5fc27ceac142762dc66680364be17b100ab0b8.tar.gz rails-2a5fc27ceac142762dc66680364be17b100ab0b8.tar.bz2 rails-2a5fc27ceac142762dc66680364be17b100ab0b8.zip |
Added AssetTagHelper that provides methods for linking a HTML page together with other assets, such as javascripts, stylesheets, and feeds.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@689 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 45 | ||||
-rw-r--r-- | actionpack/test/template/form_tag_helper_test.rb | 2 |
2 files changed, 46 insertions, 1 deletions
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb new file mode 100644 index 0000000000..a8d01f18f5 --- /dev/null +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -0,0 +1,45 @@ +require 'test/unit' +require File.dirname(__FILE__) + '/../../lib/action_view/helpers/asset_tag_helper' + +class AssetTagHelperTest < 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.world.com" + end + end + @controller = @controller.new + end + + AutoDiscoveryToTag = { + %(auto_discovery_link_tag) => %(<link href="http://www.world.com" rel="alternate" title="RSS" type="application/rss+xml" />), + %(auto_discovery_link_tag(:atom)) => %(<link href="http://www.world.com" rel="alternate" title="ATOM" type="application/atom+xml" />), + %(auto_discovery_link_tag(:rss, :action => "feed")) => %(<link href="http://www.world.com" rel="alternate" title="RSS" type="application/rss+xml" />), + } + + JavascriptIncludeToTag = { + %(javascript_include_tag("xmlhr")) => %(<script language="JavaScript" src="/javascripts/xmlhr.js" type="text/javascript"></script>), + %(javascript_include_tag("common.javascript", "/elsewhere/cools")) => %(<script language="JavaScript" src="/javascripts/common.javascript" type="text/javascript"></script>\n<script language="JavaScript" src="/elsewhere/cools.js" type="text/javascript"></script>), + } + + StyleLinkToTag = { + %(stylesheet_link_tag("style")) => %(<link href="/stylesheets/style.css" media="screen" rel="Stylesheet" type="text/css" />), + %(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" />) + } + + 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 +end
\ No newline at end of file diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 25da1937d4..6036dd4b50 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -1,7 +1,7 @@ require 'test/unit' require File.dirname(__FILE__) + '/../../lib/action_view/helpers/form_tag_helper' -class TagHelperTest < Test::Unit::TestCase +class FormTagHelperTest < Test::Unit::TestCase include ActionView::Helpers::TagHelper include ActionView::Helpers::FormTagHelper |