aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/sprockets/assets.rake10
-rw-r--r--actionpack/lib/sprockets/helpers/rails_helper.rb4
-rw-r--r--actionpack/test/template/sprockets_helper_test.rb4
3 files changed, 15 insertions, 3 deletions
diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake
index 7764bd401a..65f0ad4cc8 100644
--- a/actionpack/lib/sprockets/assets.rake
+++ b/actionpack/lib/sprockets/assets.rake
@@ -10,8 +10,7 @@ namespace :assets do
else
require "fileutils"
Rake::Task["tmp:cache:clear"].invoke
- Rails.application.initialize!(:assets)
- Sprockets::Bootstrap.new(Rails.application).run
+ Rake::Task["assets:environment"].invoke
unless Rails.application.config.assets.enabled
raise "Cannot precompile assets if sprockets is disabled. Please set config.assets.enabled to true"
@@ -40,9 +39,14 @@ namespace :assets do
end
desc "Remove compiled assets"
- task :clean => [:environment, 'tmp:cache:clear'] do
+ task :clean => ['assets:environment', 'tmp:cache:clear'] do
config = Rails.application.config
public_asset_path = File.join(Rails.public_path, config.assets.prefix)
rm_rf public_asset_path, :secure => true
end
+
+ task :environment do
+ Rails.application.initialize!(:assets)
+ Sprockets::Bootstrap.new(Rails.application).run
+ end
end
diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb
index 1e0e9bef77..fe37553fc1 100644
--- a/actionpack/lib/sprockets/helpers/rails_helper.rb
+++ b/actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -60,6 +60,10 @@ module Sprockets
options[:body] ? "#{path}?body=1" : path
end
+ def path_to_image(source)
+ asset_paths.compute_public_path(source, asset_prefix)
+ end
+
private
def debug_assets?
compile_assets? && (Rails.application.config.assets.debug || params[:debug_assets])
diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb
index 71768f4f5f..55c5bcf1b1 100644
--- a/actionpack/test/template/sprockets_helper_test.rb
+++ b/actionpack/test/template/sprockets_helper_test.rb
@@ -122,6 +122,10 @@ class SprocketsHelperTest < ActionView::TestCase
end
end
+ test "image_tag" do
+ assert_dom_equal '<img alt="Xml" src="/assets/xml.png" />', image_tag("xml.png")
+ end
+
test "stylesheets served without a controller in do not use asset hosts when the default protocol is :request" do
@controller = nil
@config.action_controller.asset_host = "assets-%d.example.com"