diff options
-rw-r--r-- | actionpack/CHANGELOG | 4 | ||||
-rw-r--r-- | actionpack/lib/sprockets/assets.rake | 1 | ||||
-rw-r--r-- | actionpack/lib/sprockets/railtie.rb | 6 | ||||
-rw-r--r-- | actionpack/test/lib/controller/fake_models.rb | 11 | ||||
-rw-r--r-- | railties/CHANGELOG | 3 | ||||
-rw-r--r-- | railties/test/application/assets_test.rb | 16 |
6 files changed, 23 insertions, 18 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index d55064bf6d..d01422b314 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -48,8 +48,12 @@ *Rails 3.1.1 (unreleased)* +* Don't mount Sprockets server at config.assets.prefix if config.assets.compile is false. [Mark J. Titorenko] + * Set relative url root in assets when controller isn't available for Sprockets (eg. Sass files using asset_path). Fixes #2435 [Guillermo Iguaran] +* Fix basic auth credential generation to not make newlines. GH #2882 + * Fixed the behavior of asset pipeline when config.assets.digest and config.assets.compile are false and requested asset isn't precompiled. Before the requested asset were compiled anyway ignoring that the config.assets.compile flag is false. [Guillermo Iguaran] diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake index b7e8f39b43..9b2f3a3f94 100644 --- a/actionpack/lib/sprockets/assets.rake +++ b/actionpack/lib/sprockets/assets.rake @@ -44,7 +44,6 @@ namespace :assets do mkdir_p filename.dirname asset.write_to(filename) asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/ - asset.write_to(target.join(logical_path)) end end end diff --git a/actionpack/lib/sprockets/railtie.rb b/actionpack/lib/sprockets/railtie.rb index dc991636a1..f05d835554 100644 --- a/actionpack/lib/sprockets/railtie.rb +++ b/actionpack/lib/sprockets/railtie.rb @@ -67,8 +67,10 @@ module Sprockets end end - app.routes.prepend do - mount app.assets => config.assets.prefix + if config.assets.compile + app.routes.prepend do + mount app.assets => config.assets.prefix + end end if config.assets.digest diff --git a/actionpack/test/lib/controller/fake_models.rb b/actionpack/test/lib/controller/fake_models.rb index cbef74f992..363403092b 100644 --- a/actionpack/test/lib/controller/fake_models.rb +++ b/actionpack/test/lib/controller/fake_models.rb @@ -48,26 +48,19 @@ module Quiz end end -class Post < Struct.new(:title, :author_name, :body, :secret, :written_on, :cost) +class Post < Struct.new(:title, :author_name, :body, :secret, :persisted, :written_on, :cost) extend ActiveModel::Naming include ActiveModel::Conversion extend ActiveModel::Translation alias_method :secret?, :secret + alias_method :persisted?, :persisted def initialize(*args) super @persisted = false end - def persisted=(boolean) - @persisted = boolean - end - - def persisted? - @persisted - end - attr_accessor :author def author_attributes=(attributes); end diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 9ba93d6130..6ed76974b4 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -12,9 +12,6 @@ *Rails 3.1.0 (unreleased)* -* Provide a way to access to assets without using the digest, useful for -static files and emails. [Santiago Pastorino] - * The default database schema file is written as UTF-8. [Aaron Patterson] * Generated apps with --dev or --edge flags depend on git versions of diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index 9245532e17..959914bcea 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -38,7 +38,7 @@ module ApplicationTests test "assets do not require compressors until it is used" do app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();" - add_to_config "config.assets.compile = true" + app_file "config/initializers/compile.rb", "Rails.application.config.assets.compile = true" ENV["RAILS_ENV"] = "production" require "#{app_path}/config/environment" @@ -58,9 +58,7 @@ module ApplicationTests Dir.chdir(app_path){ `bundle exec rake assets:precompile` } end files = Dir["#{app_path}/public/assets/application-*.js"] - files << Dir["#{app_path}/public/assets/application.js"].first files << Dir["#{app_path}/public/assets/foo/application-*.js"].first - files << Dir["#{app_path}/public/assets/foo/application.js"].first files.each do |file| assert_not_nil file, "Expected application.js asset to be generated, but none found" assert_equal "alert()", File.read(file) @@ -178,6 +176,7 @@ module ApplicationTests test "assets do not require any assets group gem when manifest file is present" do app_file "app/assets/javascripts/application.js", "alert();" + app_file "config/initializers/serve_static_assets.rb", "Rails.application.config.serve_static_assets = true" ENV["RAILS_ENV"] = "production" capture(:stdout) do @@ -314,6 +313,17 @@ module ApplicationTests assert_equal 0, files.length, "Expected no assets, but found #{files.join(', ')}" end + test "assets routes are not drawn when compilation is disabled" do + app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();" + add_to_config "config.assets.compile = false" + + ENV["RAILS_ENV"] = "production" + require "#{app_path}/config/environment" + + get "/assets/demo.js" + assert_equal 404, last_response.status + end + test "does not stream session cookies back" do app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();" |