diff options
author | José Valim <jose.valim@gmail.com> | 2011-10-05 09:35:27 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-10-05 09:37:58 +0200 |
commit | 4cea4ee6b54fee897b984a3c0288d12ce2d1efe1 (patch) | |
tree | 55823863c055ce4004c372347d6ec24ab91cce71 | |
parent | 87c57bb88f0eb1462ed31733ebcf3d9a535d8f16 (diff) | |
download | rails-4cea4ee6b54fee897b984a3c0288d12ce2d1efe1.tar.gz rails-4cea4ee6b54fee897b984a3c0288d12ce2d1efe1.tar.bz2 rails-4cea4ee6b54fee897b984a3c0288d12ce2d1efe1.zip |
Fix regression when calling helpers inside sprockets.
-rw-r--r-- | actionpack/lib/sprockets/assets.rake | 6 | ||||
-rw-r--r-- | actionpack/lib/sprockets/helpers.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/sprockets/helpers/isolated_helper.rb (renamed from actionpack/lib/sprockets/helpers/precompile_helper.rb) | 2 | ||||
-rw-r--r-- | actionpack/lib/sprockets/railtie.rb | 5 | ||||
-rw-r--r-- | railties/test/application/assets_test.rb | 4 |
5 files changed, 11 insertions, 10 deletions
diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake index 80c3d4d0b8..a5145080c2 100644 --- a/actionpack/lib/sprockets/assets.rake +++ b/actionpack/lib/sprockets/assets.rake @@ -41,10 +41,8 @@ namespace :assets do config.assets.digest = digest unless digest.nil? config.assets.digests = {} - env = Rails.application.assets - env.context_class.send :include, ::Sprockets::Helpers::PrecompileHelper - - target = File.join(Rails.public_path, config.assets.prefix) + env = Rails.application.assets + target = File.join(Rails.public_path, config.assets.prefix) compiler = Sprockets::StaticCompiler.new(env, target, config.assets.precompile, diff --git a/actionpack/lib/sprockets/helpers.rb b/actionpack/lib/sprockets/helpers.rb index cd9c8f62e6..fee48386e0 100644 --- a/actionpack/lib/sprockets/helpers.rb +++ b/actionpack/lib/sprockets/helpers.rb @@ -1,6 +1,6 @@ module Sprockets module Helpers - autoload :RailsHelper, "sprockets/helpers/rails_helper" - autoload :PrecompileHelper, "sprockets/helpers/precompile_helper" + autoload :RailsHelper, "sprockets/helpers/rails_helper" + autoload :IsolatedHelper, "sprockets/helpers/isolated_helper" end end diff --git a/actionpack/lib/sprockets/helpers/precompile_helper.rb b/actionpack/lib/sprockets/helpers/isolated_helper.rb index ca7927f6fb..3adb928c45 100644 --- a/actionpack/lib/sprockets/helpers/precompile_helper.rb +++ b/actionpack/lib/sprockets/helpers/isolated_helper.rb @@ -1,6 +1,6 @@ module Sprockets module Helpers - module PrecompileHelper + module IsolatedHelper def controller nil end diff --git a/actionpack/lib/sprockets/railtie.rb b/actionpack/lib/sprockets/railtie.rb index e29612d320..3d330bd91a 100644 --- a/actionpack/lib/sprockets/railtie.rb +++ b/actionpack/lib/sprockets/railtie.rb @@ -43,7 +43,10 @@ module Sprockets ActiveSupport.on_load(:action_view) do include ::Sprockets::Helpers::RailsHelper - app.assets.context_class.send :include, ::Sprockets::Helpers::RailsHelper + app.assets.context_class.instance_eval do + include ::Sprockets::Helpers::IsolatedHelper + include ::Sprockets::Helpers::RailsHelper + end end end diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index e38ea30c30..63427c7792 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -28,7 +28,7 @@ module ApplicationTests end test "assets routes have higher priority" do - app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();" + app_file "app/assets/javascripts/demo.js.erb", "a = <%= image_path('rails.png').inspect %>;" app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do @@ -39,7 +39,7 @@ module ApplicationTests require "#{app_path}/config/environment" get "/assets/demo.js" - assert_match "alert()", last_response.body + assert_equal 'a = "/assets/rails.png";', last_response.body.strip end test "assets do not require compressors until it is used" do |