Permalink
Browse files

CoC: if you are precompiling you want a manifest.yml, if you have a m…

…anifest.yml you want use it and don't fallback to live compiling
  • Loading branch information...
1 parent 27ac20d commit e43fa07cfcfcc3f7359832fad6731945928e251b @guilleiguaran committed Aug 30, 2011
View
6 actionpack/lib/sprockets/assets.rake
@@ -46,10 +46,8 @@ namespace :assets do
env.precompile(*assets)
end
- if config.assets.manifest
- File.open("#{target}/manifest.yml", 'w') do |f|
- YAML.dump(manifest, f)
- end
+ File.open("#{target}/manifest.yml", 'w') do |f|
+ YAML.dump(manifest, f)
end
end
end
View
8 actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -108,14 +108,12 @@ def asset_for(source, ext)
end
def digest_for(logical_path)
- if asset_digests && (digest = asset_digests[logical_path])
+ if asset_digests
+ digest = asset_digests[logical_path]
+ raise AssetNotPrecompiledError unless digest
return digest
end
- if digest.nil? && Rails.application.config.assets.precompile_only
- raise AssetNotPrecompiledError
- end
-
if asset = asset_environment[logical_path]
return asset.digest_path
end
View
6 actionpack/lib/sprockets/railtie.rb
@@ -26,10 +26,8 @@ class Railtie < ::Rails::Railtie
end
end
- if config.assets.manifest
- if File.exist?(path = File.join(Rails.public_path, config.assets.prefix, "manifest.yml"))
- config.assets.digests = YAML.load_file(path)
- end
+ if File.exist?(path = File.join(Rails.public_path, config.assets.prefix, "manifest.yml"))
+ config.assets.digests = YAML.load_file(path)
end
ActiveSupport.on_load(:action_view) do
View
2 railties/lib/rails/application/configuration.rb
@@ -42,8 +42,6 @@ def initialize(*)
@assets.version = ''
@assets.debug = false
@assets.allow_debugging = false
- @assets.manifest = true
- @assets.precompile_only = false
@assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
@assets.js_compressor = nil
@assets.css_compressor = nil
View
4 railties/lib/rails/generators/rails/app/templates/config/application.rb
@@ -52,10 +52,6 @@ class Application < Rails::Application
<% unless options.skip_sprockets? -%>
# Enable the asset pipeline
config.assets.enabled = true
-
- # Create a manifest with the hashes of your assets when you run "rake assets:precompile".
- # Use this if you don't have a JavaScript engine in your production servers
- config.assets.manifest = true
<% end -%>
end
end
View
26 railties/test/application/assets_test.rb
@@ -62,18 +62,7 @@ def app
end
end
- test "precompile don't create a manifest file when manifest option is off" do
- app_file "app/assets/javascripts/application.js", "alert();"
- app_file "config/initializers/manifest.rb", "Rails.application.config.assets.manifest = false"
-
- capture(:stdout) do
- Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
- end
-
- assert !File.exist?("#{app_path}/public/assets/manifest.yml")
- end
-
- test "precompile creates a manifest file with all the assets listed when manifest option is on" do
+ test "precompile creates a manifest file with all the assets listed" do
app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>"
app_file "app/assets/javascripts/application.js", "alert();"
@@ -88,7 +77,7 @@ def app
assert_match /application-([0-z]+)\.css/, assets["application.css"]
end
- test "assets do not require any assets group gem when manifest option is on and manifest file is present" do
+ test "assets do not require any assets group gem when manifest file is present" do
app_file "app/assets/javascripts/application.js", "alert();"
ENV["RAILS_ENV"] = "production"
@@ -108,10 +97,8 @@ def app
assert !defined?(Uglifier)
end
- test "assets raise AssetNotPrecompiledError if config.assets.precompile_only is on and file isn't precompiled" do
- app_file "app/assets/javascripts/app.js", "alert();"
+ test "assets raise AssetNotPrecompiledError when manifest file is present and requested file isn't precompiled" do
app_file "app/views/posts/index.html.erb", "<%= javascript_include_tag 'app' %>"
- app_file "config/initializers/precompile_only.rb", "Rails.application.config.assets.precompile_only = true"
app_file "config/routes.rb", <<-RUBY
AppTemplate::Application.routes.draw do
@@ -120,6 +107,13 @@ def app
RUBY
ENV["RAILS_ENV"] = "production"
+ capture(:stdout) do
+ Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
+ end
+
+ # Create file after of precompile
+ app_file "app/assets/javascripts/app.js", "alert();"
+
require "#{app_path}/config/environment"
class ::PostsController < ActionController::Base ; end

0 comments on commit e43fa07

Please sign in to comment.