Permalink
Browse files

Fix regression when calling helpers inside sprockets.

  • Loading branch information...
1 parent 87c57bb commit 4cea4ee6b54fee897b984a3c0288d12ce2d1efe1 @josevalim josevalim committed Oct 5, 2011
@@ -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,
@@ -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
@@ -1,6 +1,6 @@
module Sprockets
module Helpers
- module PrecompileHelper
+ module IsolatedHelper
def controller
nil
end
@@ -43,7 +43,10 @@ class Railtie < ::Rails::Railtie
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
@@ -28,7 +28,7 @@ def precompile!
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 @@ def precompile!
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

0 comments on commit 4cea4ee

Please sign in to comment.