Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Correctly override image_path in sprockets rails_helper

  • Loading branch information...
commit b8ea31540a7f3b195a211457a73de7a22b30059b 1 parent 89e98e2
Christos Zisopoulos christos authored
3  actionpack/lib/sprockets/helpers/rails_helper.rb
View
@@ -60,9 +60,10 @@ def asset_path(source, options = {})
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?
8 actionpack/test/template/sprockets_helper_test.rb
View
@@ -126,6 +126,14 @@ def url_for(*args)
assert_dom_equal '<img alt="Xml" src="/assets/xml.png" />', 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"
Please sign in to comment.
Something went wrong with that request. Please try again.