aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-12-01 04:18:41 -0800
committerJosé Valim <jose.valim@gmail.com>2011-12-01 04:18:41 -0800
commitf8b934224fec676a7f169caf9c2d0e61ca5c9a35 (patch)
tree822b78cb2d4d925e534ca403cd6df508afbeef06 /railties
parentcb7145700d6fd31ef316d97590815ce73bb08cbd (diff)
parent88237daae48c9867fca3b0e14e779d4f4cdd88d0 (diff)
downloadrails-f8b934224fec676a7f169caf9c2d0e61ca5c9a35.tar.gz
rails-f8b934224fec676a7f169caf9c2d0e61ca5c9a35.tar.bz2
rails-f8b934224fec676a7f169caf9c2d0e61ca5c9a35.zip
Merge pull request #3660 from jdelStrother/asset_protocol
default_asset_host_protocol should not default to :relative
Diffstat (limited to 'railties')
-rw-r--r--railties/test/application/assets_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb
index d4ffbe3d66..a22013f81c 100644
--- a/railties/test/application/assets_test.rb
+++ b/railties/test/application/assets_test.rb
@@ -451,6 +451,28 @@ module ApplicationTests
assert_equal 0, files.length, "Expected application.js asset to be removed, but still exists"
end
+ test "asset urls should use the request's protocol by default" do
+ app_with_assets_in_view
+ add_to_config "config.asset_host = 'example.com'"
+ require "#{app_path}/config/environment"
+ class ::PostsController < ActionController::Base; end
+
+ get '/posts', {}, {'HTTPS'=>'off'}
+ assert_match('src="http://example.com/assets/application.js', last_response.body)
+ get '/posts', {}, {'HTTPS'=>'on'}
+ assert_match('src="https://example.com/assets/application.js', last_response.body)
+ end
+
+ test "asset urls should be protocol-relative if no request is in scope" do
+ app_file "app/assets/javascripts/image_loader.js.erb", 'var src="<%= image_path("rails.png") %>";'
+ add_to_config "config.assets.precompile = %w{image_loader.js}"
+ add_to_config "config.asset_host = 'example.com'"
+ precompile!
+
+ assert_match 'src="//example.com/assets/rails.png"', File.read("#{app_path}/public/assets/image_loader.js")
+ end
+
+
private
def app_with_assets_in_view