aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2011-03-29 15:42:31 -0500
committerJoshua Peek <josh@joshpeek.com>2011-03-29 15:42:31 -0500
commit1af295fc9a6772e587e438254cfe354e6da0fa19 (patch)
treebefb6c09021bad1bb4982bdfca769083fcc3b587 /actionpack/lib
parent3b4e1a91590b27f6f874927dc51f6f1755ae9f19 (diff)
downloadrails-1af295fc9a6772e587e438254cfe354e6da0fa19.tar.gz
rails-1af295fc9a6772e587e438254cfe354e6da0fa19.tar.bz2
rails-1af295fc9a6772e587e438254cfe354e6da0fa19.zip
Tests for SprocketsHelper
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/sprockets_helper.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/helpers/sprockets_helper.rb b/actionpack/lib/action_view/helpers/sprockets_helper.rb
index bfc396fad5..f6f4f06d6e 100644
--- a/actionpack/lib/action_view/helpers/sprockets_helper.rb
+++ b/actionpack/lib/action_view/helpers/sprockets_helper.rb
@@ -9,7 +9,7 @@ module ActionView
def sprockets_javascript_include_tag(source, options = {})
options = {
- 'type' => "application/javascript",
+ 'type' => "text/javascript",
'src' => sprockets_javascript_path(source)
}.merge(options.stringify_keys)
@@ -33,6 +33,8 @@ module ActionView
private
def compute_sprockets_path(source, dir, default_ext)
+ source = source.to_s
+
return source if URI.parse(source).host
# Add /javscripts to relative paths
@@ -46,15 +48,15 @@ module ActionView
end
# Fingerprint url
- source = Rails.application.assets.path(source)
+ source = assets.path(source)
host = compute_asset_host(source)
- if controller.respond_to?(:request) && host && URI.parse(host).host.nil?
- host = "#{controller.request.protocol}#{host}"
+ if controller.respond_to?(:request) && host && URI.parse(host).host
+ source = "#{controller.request.protocol}#{host}#{source}"
end
- "#{host}#{source}"
+ source
end
def compute_asset_host(source)
@@ -72,6 +74,10 @@ module ActionView
end
end
end
+
+ def assets
+ Rails.application.assets
+ end
end
end
end