diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-09-28 20:13:24 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-09-28 20:13:24 -0300 |
commit | 64b0c8888b908ede5372e0a70cb4cb8731d372ba (patch) | |
tree | d0e73d457ff98985e3a155a8cba141dfa317b585 /actionpack | |
parent | ad304e9f7e4f244eabfd42e7cd768e3b41725875 (diff) | |
download | rails-64b0c8888b908ede5372e0a70cb4cb8731d372ba.tar.gz rails-64b0c8888b908ede5372e0a70cb4cb8731d372ba.tar.bz2 rails-64b0c8888b908ede5372e0a70cb4cb8731d372ba.zip |
javascript_path and stylesheet_path should honor the asset pipelining
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/sprockets/helpers/rails_helper.rb | 10 | ||||
-rw-r--r-- | actionpack/test/template/sprockets_helper_test.rb | 20 |
2 files changed, 28 insertions, 2 deletions
diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index c8c6c3ddd9..e1d8fccf04 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -65,6 +65,16 @@ module Sprockets end alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route + def javascript_path(source) + asset_path(source) + end + alias_method :path_to_javascript, :javascript_path # aliased to avoid conflicts with an javascript_path named route + + def stylesheet_path(source) + asset_path(source) + end + alias_method :path_to_stylesheet, :stylesheet_path # aliased to avoid conflicts with an stylesheet_path named route + private def debug_assets? compile_assets? && (Rails.application.config.assets.debug || params[:debug_assets]) diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index b1e6db7b34..fd3e01ec03 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -134,6 +134,22 @@ class SprocketsHelperTest < ActionView::TestCase path_to_image("logo.png") end + test "javascript_path" do + assert_match %r{/assets/application-[0-9a-f]+.js}, + javascript_path("application.js") + + assert_match %r{/assets/application-[0-9a-f]+.js}, + path_to_javascript("application.js") + end + + test "stylesheet_path" do + assert_match %r{/assets/application-[0-9a-f]+.css}, + stylesheet_path("application.css") + + assert_match %r{/assets/application-[0-9a-f]+.css}, + path_to_stylesheet("application.css") + end + test "stylesheets served without a controller in do not use asset hosts when the default protocol is :request" do @controller = nil @config.action_controller.asset_host = "assets-%d.example.com" @@ -157,7 +173,7 @@ class SprocketsHelperTest < ActionView::TestCase asset_path("/images/logo.gif") end - test "javascript path" do + test "javascript path through asset_path" do assert_match %r{/assets/application-[0-9a-f]+.js}, asset_path(:application, :ext => "js") @@ -202,7 +218,7 @@ class SprocketsHelperTest < ActionView::TestCase javascript_include_tag(:application) end - test "stylesheet path" do + test "stylesheet path through asset_path" do assert_match %r{/assets/application-[0-9a-f]+.css}, asset_path(:application, :ext => "css") assert_match %r{/assets/style-[0-9a-f]+.css}, asset_path("style", :ext => "css") |