diff options
Diffstat (limited to 'actionpack/test/template/sprockets_helper_test.rb')
-rw-r--r-- | actionpack/test/template/sprockets_helper_test.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index db69f95130..1c591bdcc2 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -24,6 +24,7 @@ class SprocketsHelperTest < ActionView::TestCase @assets.append_path(FIXTURES.join("sprockets/app/javascripts")) @assets.append_path(FIXTURES.join("sprockets/app/stylesheets")) @assets.append_path(FIXTURES.join("sprockets/app/images")) + @assets.append_path(FIXTURES.join("sprockets/app/fonts")) application = Struct.new(:config, :assets).new(config, @assets) Rails.stubs(:application).returns(application) @@ -41,6 +42,10 @@ class SprocketsHelperTest < ActionView::TestCase @controller ? @controller.config : @config end + def compute_host(source, request, options = {}) + raise "Should never get here" + end + test "asset_path" do assert_match %r{/assets/logo-[0-9a-f]+.png}, asset_path("logo.png") @@ -125,6 +130,10 @@ class SprocketsHelperTest < ActionView::TestCase assert_raises ActionController::RoutingError do asset_path("logo.png") end + @config.asset_host = method :compute_host + assert_raises ActionController::RoutingError do + asset_path("logo.png") + end end test "image_tag" do @@ -139,8 +148,19 @@ class SprocketsHelperTest < ActionView::TestCase path_to_image("logo.png") end + test "font_path" do + assert_match %r{/assets/font-[0-9a-f]+.ttf}, + font_path("font.ttf") + + assert_match %r{/assets/font-[0-9a-f]+.ttf}, + path_to_font("font.ttf") + end + test "javascript_path" do assert_match %r{/assets/application-[0-9a-f]+.js}, + javascript_path("application") + + assert_match %r{/assets/application-[0-9a-f]+.js}, javascript_path("application.js") assert_match %r{/assets/application-[0-9a-f]+.js}, @@ -149,6 +169,9 @@ class SprocketsHelperTest < ActionView::TestCase test "stylesheet_path" do assert_match %r{/assets/application-[0-9a-f]+.css}, + stylesheet_path("application") + + assert_match %r{/assets/application-[0-9a-f]+.css}, stylesheet_path("application.css") assert_match %r{/assets/application-[0-9a-f]+.css}, @@ -178,6 +201,17 @@ class SprocketsHelperTest < ActionView::TestCase asset_path("/images/logo.gif") end + test "font path through asset_path" do + assert_match %r{/assets/font-[0-9a-f]+.ttf}, + asset_path('font.ttf') + + assert_match %r{/assets/dir/font-[0-9a-f]+.ttf}, + asset_path("dir/font.ttf") + + assert_equal "http://www.example.com/fonts/font.ttf", + asset_path("http://www.example.com/fonts/font.ttf") + end + test "javascript path through asset_path" do assert_match %r{/assets/application-[0-9a-f]+.js}, asset_path(:application, :ext => "js") @@ -217,6 +251,9 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js\?body=1" type="text/javascript"></script>\n<script src="/assets/application-[0-9a-f]+.js\?body=1" type="text/javascript"></script>}, javascript_include_tag(:application, :debug => true) + assert_match %r{<script src="/assets/jquery.plugin.js" type="text/javascript"></script>}, + javascript_include_tag('jquery.plugin', :digest => false) + @config.assets.compile = true @config.assets.debug = true assert_match %r{<script src="/javascripts/application.js" type="text/javascript"></script>}, |