diff options
-rw-r--r-- | actionpack/lib/sprockets/assets.rake | 9 | ||||
-rw-r--r-- | actionpack/lib/sprockets/helpers/rails_helper.rb | 13 | ||||
-rw-r--r-- | actionpack/lib/sprockets/railtie.rb | 5 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 2 |
4 files changed, 21 insertions, 8 deletions
diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake index 4cf5caab91..acf2f256c2 100644 --- a/actionpack/lib/sprockets/assets.rake +++ b/actionpack/lib/sprockets/assets.rake @@ -13,17 +13,20 @@ namespace :assets do # Ensure that action view is loaded and the appropriate sprockets hooks get executed ActionView::Base - assets = Rails.application.config.assets.precompile # Always perform caching so that asset_path appends the timestamps to file references. Rails.application.config.action_controller.perform_caching = true + + config = Rails.application.config + assets = config.assets.precompile.dup + assets << {:to => File.join(Rails.public_path, config.assets.prefix)} Rails.application.assets.precompile(*assets) end end desc "Remove compiled assets" task :clean => [:environment, 'tmp:cache:clear'] do - assets = Rails.application.config.assets - public_asset_path = Rails.public_path + assets.prefix + config = Rails.application.config + public_asset_path = File.join(Rails.public_path, config.assets.prefix) rm_rf public_asset_path, :secure => true end end diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index a65c5992ca..69306ef631 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -112,11 +112,22 @@ module Sprockets asset_environment[source] end + def digest_for(logical_path) + if asset = asset_environment[logical_path] + return asset.digest_path + end + + logical_path + end + def rewrite_asset_path(source, dir) if source[0] == ?/ source else - asset_environment.path(source, performing_caching?, dir) + source = digest_for(source) if performing_caching? + source = File.join(dir, source) + source = "/#{url}" unless source =~ /^\// + source end end diff --git a/actionpack/lib/sprockets/railtie.rb b/actionpack/lib/sprockets/railtie.rb index 0a2c8c1ea3..c21bf57935 100644 --- a/actionpack/lib/sprockets/railtie.rb +++ b/actionpack/lib/sprockets/railtie.rb @@ -18,9 +18,8 @@ module Sprockets require 'sprockets' app.assets = Sprockets::Environment.new(app.root.to_s) do |env| - env.static_root = File.join(app.root.join('public'), config.assets.prefix) - env.logger = ::Rails.logger - env.version = ::Rails.env + "#{'-' + config.assets.version if config.assets.version.present?}" + env.logger = ::Rails.logger + env.version = ::Rails.env + "-#{config.assets.version}" if config.assets.cache_store != false env.cache = ActiveSupport::Cache.lookup_store(config.assets.cache_store) || ::Rails.cache diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index fb7ebaa1fa..2415195a17 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -189,7 +189,7 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_file "test/performance/browsing_test.rb" end - def test_generator_if_skip_active_record_is_given + def test_generator_if_skip_sprockets_is_given run_generator [destination_root, "--skip-sprockets"] assert_file "config/application.rb" do |content| assert_match(/#\s+require\s+["']sprockets\/railtie["']/, content) |