diff options
author | Tieg Zaharia <tieg.zaharia@gmail.com> | 2009-06-26 14:38:18 -0400 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-07-02 10:36:38 -0700 |
commit | 51d7b3070c68492f5376c19d24d8e5a2d746d7ea (patch) | |
tree | a3302e0f244589e854dcdcd3919bf1454058fbab /actionpack/test/template | |
parent | 9eab435631e1b0a659126d068972ee88cff160de (diff) | |
download | rails-51d7b3070c68492f5376c19d24d8e5a2d746d7ea.tar.gz rails-51d7b3070c68492f5376c19d24d8e5a2d746d7ea.tar.bz2 rails-51d7b3070c68492f5376c19d24d8e5a2d746d7ea.zip |
Adds a video_tag helper for the HTML5 video tag (similar to how the image_tag works) (tests included); removes a duplicate test line for image_tag; adds boolean attributes for video tag to tag()'s boolean attributes
Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 65289a59bc..e7d70302f8 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -138,11 +138,38 @@ class AssetTagHelperTest < ActionView::TestCase %(image_tag("error.png", "size" => "45 x 70")) => %(<img alt="Error" src="/images/error.png" />), %(image_tag("error.png", "size" => "x")) => %(<img alt="Error" src="/images/error.png" />), %(image_tag("http://www.rubyonrails.com/images/rails.png")) => %(<img alt="Rails" src="http://www.rubyonrails.com/images/rails.png" />), - %(image_tag("http://www.rubyonrails.com/images/rails.png")) => %(<img alt="Rails" src="http://www.rubyonrails.com/images/rails.png" />), %(image_tag("mouse.png", :mouseover => "/images/mouse_over.png")) => %(<img alt="Mouse" onmouseover="this.src='/images/mouse_over.png'" onmouseout="this.src='/images/mouse.png'" src="/images/mouse.png" />), %(image_tag("mouse.png", :mouseover => image_path("mouse_over.png"))) => %(<img alt="Mouse" onmouseover="this.src='/images/mouse_over.png'" onmouseout="this.src='/images/mouse.png'" src="/images/mouse.png" />) } + VideoPathToTag = { + %(video_path("xml")) => %(/videos/xml), + %(video_path("xml.ogg")) => %(/videos/xml.ogg), + %(video_path("dir/xml.ogg")) => %(/videos/dir/xml.ogg), + %(video_path("/dir/xml.ogg")) => %(/dir/xml.ogg) + } + + PathToVideoToTag = { + %(path_to_video("xml")) => %(/videos/xml), + %(path_to_video("xml.ogg")) => %(/videos/xml.ogg), + %(path_to_video("dir/xml.ogg")) => %(/videos/dir/xml.ogg), + %(path_to_video("/dir/xml.ogg")) => %(/dir/xml.ogg) + } + + VideoLinkToTag = { + %(video_tag("xml.ogg")) => %(<video src="/videos/xml.ogg" />), + %(video_tag("rss.m4v", :autoplay => true, :controls => true)) => %(<video autoplay="autoplay" controls="controls" src="/videos/rss.m4v" />), + %(video_tag("rss.m4v", :autobuffer => true)) => %(<video autobuffer="autobuffer" src="/videos/rss.m4v" />), + %(video_tag("gold.m4v", :size => "160x120")) => %(<video height="120" src="/videos/gold.m4v" width="160" />), + %(video_tag("gold.m4v", "size" => "320x240")) => %(<video height="240" src="/videos/gold.m4v" width="320" />), + %(video_tag("trailer.ogg", :poster => "screenshot.png")) => %(<video poster="/images/screenshot.png" src="/videos/trailer.ogg" />), + %(video_tag("error.avi", "size" => "100")) => %(<video src="/videos/error.avi" />), + %(video_tag("error.avi", "size" => "100 x 100")) => %(<video src="/videos/error.avi" />), + %(video_tag("error.avi", "size" => "x")) => %(<video src="/videos/error.avi" />), + %(video_tag("http://media.rubyonrails.org/video/rails_blog_2.mov")) => %(<video src="http://media.rubyonrails.org/video/rails_blog_2.mov" />), + %(video_tag(["multiple.ogg", "multiple.avi"])) => %(<video><source src="multiple.ogg" /><source src="multiple.avi" /></video>), + %(video_tag(["multiple.ogg", "multiple.avi"], :size => "160x120", :controls => true)) => %(<video controls="controls" height="120" width="160"><source src="multiple.ogg" /><source src="multiple.avi" /></video>) + } def test_auto_discovery_link_tag AutoDiscoveryToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } @@ -272,6 +299,18 @@ class AssetTagHelperTest < ActionView::TestCase end end + def test_video_path + VideoPathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } + end + + def test_path_to_video_alias_for_video_path + PathToVideoToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } + end + + def test_video_tag + VideoLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } + end + def test_timebased_asset_id expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s assert_equal %(<img alt="Rails" src="/images/rails.png?#{expected_time}" />), image_tag("rails.png") @@ -284,7 +323,7 @@ class AssetTagHelperTest < ActionView::TestCase ensure ActionController::Base.relative_url_root = "" end - + def test_should_skip_asset_id_on_complete_url assert_equal %(<img alt="Rails" src="http://www.example.com/rails.png" />), image_tag("http://www.example.com/rails.png") end |