diff options
author | kennyj <kennyj@gmail.com> | 2011-09-13 02:59:57 +0900 |
---|---|---|
committer | kennyj <kennyj@gmail.com> | 2011-09-13 02:59:57 +0900 |
commit | 21eaba4c39773af3e7b279325fb8d6b5ab474ef0 (patch) | |
tree | 50438d70a6d02b9699a9ebd65eb8ed76c29080fb | |
parent | 3ce830272ee0516eb864a5765abba25d4b07cca4 (diff) | |
download | rails-21eaba4c39773af3e7b279325fb8d6b5ab474ef0.tar.gz rails-21eaba4c39773af3e7b279325fb8d6b5ab474ef0.tar.bz2 rails-21eaba4c39773af3e7b279325fb8d6b5ab474ef0.zip |
fix https://github.com/rails/rails/issues/2947 (with testcase)
-rw-r--r-- | actionpack/lib/sprockets/assets.rake | 3 | ||||
-rw-r--r-- | railties/test/application/rake_test.rb | 16 |
2 files changed, 19 insertions, 0 deletions
diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake index 2e415bf6cc..7e0c7cac52 100644 --- a/actionpack/lib/sprockets/assets.rake +++ b/actionpack/lib/sprockets/assets.rake @@ -16,6 +16,9 @@ namespace :assets do # Always compile files Rails.application.config.assets.compile = true + # Always ignore asset host + Rails.application.config.action_controller.asset_host = nil + config = Rails.application.config env = Rails.application.assets target = Pathname.new(File.join(Rails.public_path, config.assets.prefix)) diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 9b1b24fca1..721a8c978f 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -260,5 +260,21 @@ module ApplicationTests end end + def test_assets_precompile_ignore_asset_host + add_to_config <<-RUBY + config.action_controller.asset_host = Proc.new { |source, request| "http://www.example.com/" } + RUBY + + app_file "app/assets/javascripts/test.js.erb", <<-RUBY + alert("<%= asset_path "rails.png" %>"); + RUBY + + Dir.chdir(app_path) do + `rake assets:precompile` + open("public/assets/application.js") do |f| + assert_match(/\"\/assets\/rails.png\"/, f.read) + end + end + end end end |