From b8ea31540a7f3b195a211457a73de7a22b30059b Mon Sep 17 00:00:00 2001 From: Christos Zisopoulos Date: Mon, 26 Sep 2011 18:45:49 +0200 Subject: Correctly override image_path in sprockets rails_helper --- actionpack/lib/sprockets/helpers/rails_helper.rb | 3 ++- actionpack/test/template/sprockets_helper_test.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index fe37553fc1..b60165de5b 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -60,9 +60,10 @@ module Sprockets options[:body] ? "#{path}?body=1" : path end - def path_to_image(source) + def image_path(source) asset_paths.compute_public_path(source, asset_prefix) end + alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route private def debug_assets? diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index ad57bbd96c..b1e6db7b34 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -126,6 +126,14 @@ class SprocketsHelperTest < ActionView::TestCase assert_dom_equal 'Xml', image_tag("xml.png") end + test "image_path" do + assert_match %r{/assets/logo-[0-9a-f]+.png}, + image_path("logo.png") + + assert_match %r{/assets/logo-[0-9a-f]+.png}, + path_to_image("logo.png") + 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" -- cgit v1.2.3