From 88827a2cab6867f3207022a5fde3d184e03b3972 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Mon, 15 Sep 2014 14:35:28 +1000 Subject: [PATCH] rip out a bunch of sprockets stuff --- actionpack/lib/sprockets/assets.rake | 99 ---- actionpack/lib/sprockets/bootstrap.rb | 37 -- actionpack/lib/sprockets/compressors.rb | 83 --- actionpack/lib/sprockets/helpers.rb | 6 - .../lib/sprockets/helpers/isolated_helper.rb | 13 - .../lib/sprockets/helpers/rails_helper.rb | 182 ------ actionpack/lib/sprockets/railtie.rb | 62 -- actionpack/lib/sprockets/static_compiler.rb | 56 -- actionpack/test/template/compressors_test.rb | 28 - .../test/template/sprockets_helper_test.rb | 392 ------------ .../sprockets_helper_with_routes_test.rb | 57 -- railties/test/application/assets_test.rb | 556 ------------------ 12 files changed, 1571 deletions(-) delete mode 100644 actionpack/lib/sprockets/assets.rake delete mode 100644 actionpack/lib/sprockets/bootstrap.rb delete mode 100644 actionpack/lib/sprockets/compressors.rb delete mode 100644 actionpack/lib/sprockets/helpers.rb delete mode 100644 actionpack/lib/sprockets/helpers/isolated_helper.rb delete mode 100644 actionpack/lib/sprockets/helpers/rails_helper.rb delete mode 100644 actionpack/lib/sprockets/railtie.rb delete mode 100644 actionpack/lib/sprockets/static_compiler.rb delete mode 100644 actionpack/test/template/compressors_test.rb delete mode 100644 actionpack/test/template/sprockets_helper_test.rb delete mode 100644 actionpack/test/template/sprockets_helper_with_routes_test.rb delete mode 100644 railties/test/application/assets_test.rb diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake deleted file mode 100644 index 3bf8571d11..0000000000 --- a/actionpack/lib/sprockets/assets.rake +++ /dev/null @@ -1,99 +0,0 @@ -require "fileutils" - -namespace :assets do - def ruby_rake_task(task, fork = true) - env = ENV['RAILS_ENV'] || 'production' - groups = ENV['RAILS_GROUPS'] || 'assets' - args = [$0, task,"RAILS_ENV=#{env}","RAILS_GROUPS=#{groups}"] - args << "--trace" if Rake.application.options.trace - if $0 =~ /rake\.bat\Z/i - Kernel.exec $0, *args - else - fork ? ruby(*args) : Kernel.exec(FileUtils::RUBY, *args) - end - end - - # We are currently running with no explicit bundler group - # and/or no explicit environment - we have to reinvoke rake to - # execute this task. - def invoke_or_reboot_rake_task(task) - if ENV['RAILS_GROUPS'].to_s.empty? || ENV['RAILS_ENV'].to_s.empty? - ruby_rake_task task - else - Rake::Task[task].invoke - end - end - - desc "Compile all the assets named in config.assets.precompile" - task :precompile do - invoke_or_reboot_rake_task "assets:precompile:all" - end - - namespace :precompile do - def internal_precompile(digest=nil) - unless Rails.application.config.assets.enabled - warn "Cannot precompile assets if sprockets is disabled. Please set config.assets.enabled to true" - exit - end - - # Ensure that action view is loaded and the appropriate - # sprockets hooks get executed - _ = ActionView::Base - - config = Rails.application.config - config.assets.compile = true - config.assets.digest = digest unless digest.nil? - config.assets.digests = {} - - env = Rails.application.assets - target = File.join(Rails.public_path, config.assets.prefix) - compiler = Sprockets::StaticCompiler.new(env, - target, - config.assets.precompile, - :manifest_path => config.assets.manifest, - :digest => config.assets.digest, - :manifest => digest.nil?) - compiler.compile - end - - task :all do - Rake::Task["assets:precompile:primary"].invoke - # We need to reinvoke in order to run the secondary digestless - # asset compilation run - a fresh Sprockets environment is - # required in order to compile digestless assets as the - # environment has already cached the assets on the primary - # run. - ruby_rake_task("assets:precompile:nondigest", false) if Rails.application.config.assets.digest - end - - task :primary => ["assets:environment", "tmp:cache:clear"] do - internal_precompile - end - - task :nondigest => ["assets:environment", "tmp:cache:clear"] do - internal_precompile(false) - end - end - - desc "Remove compiled assets" - task :clean do - invoke_or_reboot_rake_task "assets:clean:all" - end - - namespace :clean do - task :all => ["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 - end - - task :environment do - if Rails.application.config.assets.initialize_on_precompile - Rake::Task["environment"].invoke - else - Rails.application.initialize!(:assets) - Sprockets::Bootstrap.new(Rails.application).run - end - end -end diff --git a/actionpack/lib/sprockets/bootstrap.rb b/actionpack/lib/sprockets/bootstrap.rb deleted file mode 100644 index 395b264fe7..0000000000 --- a/actionpack/lib/sprockets/bootstrap.rb +++ /dev/null @@ -1,37 +0,0 @@ -module Sprockets - class Bootstrap - def initialize(app) - @app = app - end - - # TODO: Get rid of config.assets.enabled - def run - app, config = @app, @app.config - return unless app.assets - - config.assets.paths.each { |path| app.assets.append_path(path) } - - if config.assets.compress - # temporarily hardcode default JS compressor to uglify. Soon, it will work - # the same as SCSS, where a default plugin sets the default. - unless config.assets.js_compressor == false - app.assets.js_compressor = LazyCompressor.new { Sprockets::Compressors.registered_js_compressor(config.assets.js_compressor || :uglifier) } - end - - unless config.assets.css_compressor == false - app.assets.css_compressor = LazyCompressor.new { Sprockets::Compressors.registered_css_compressor(config.assets.css_compressor) } - end - end - - if config.assets.compile - app.routes.prepend do - mount app.assets => config.assets.prefix - end - end - - if config.assets.digest - app.assets = app.assets.index - end - end - end -end diff --git a/actionpack/lib/sprockets/compressors.rb b/actionpack/lib/sprockets/compressors.rb deleted file mode 100644 index cb3e13314b..0000000000 --- a/actionpack/lib/sprockets/compressors.rb +++ /dev/null @@ -1,83 +0,0 @@ -module Sprockets - module Compressors - @@css_compressors = {} - @@js_compressors = {} - @@default_css_compressor = nil - @@default_js_compressor = nil - - def self.register_css_compressor(name, klass, options = {}) - @@default_css_compressor = name.to_sym if options[:default] || @@default_css_compressor.nil? - @@css_compressors[name.to_sym] = {:klass => klass.to_s, :require => options[:require]} - end - - def self.register_js_compressor(name, klass, options = {}) - @@default_js_compressor = name.to_sym if options[:default] || @@default_js_compressor.nil? - @@js_compressors[name.to_sym] = {:klass => klass.to_s, :require => options[:require]} - end - - def self.registered_css_compressor(name) - if name.respond_to?(:to_sym) - compressor = @@css_compressors[name.to_sym] || @@css_compressors[@@default_css_compressor] - require compressor[:require] if compressor[:require] - compressor[:klass].constantize.new - else - name - end - end - - def self.registered_js_compressor(name) - if name.respond_to?(:to_sym) - compressor = @@js_compressors[name.to_sym] || @@js_compressors[@@default_js_compressor] - require compressor[:require] if compressor[:require] - compressor[:klass].constantize.new - else - name - end - end - - # The default compressors must be registered in default plugins (ex. Sass-Rails) - register_css_compressor(:scss, 'Sass::Rails::Compressor', :require => 'sass/rails/compressor', :default => true) - register_js_compressor(:uglifier, 'Uglifier', :require => 'uglifier', :default => true) - - # Automaticaly register some compressors - register_css_compressor(:yui, 'YUI::CssCompressor', :require => 'yui/compressor') - register_js_compressor(:closure, 'Closure::Compiler', :require => 'closure-compiler') - register_js_compressor(:yui, 'YUI::JavaScriptCompressor', :require => 'yui/compressor') - end - - # An asset compressor which does nothing. - # - # This compressor simply returns the asset as-is, without any compression - # whatsoever. It is useful in development mode, when compression isn't - # needed but using the same asset pipeline as production is desired. - class NullCompressor #:nodoc: - def compress(content) - content - end - end - - # An asset compressor which only initializes the underlying compression - # engine when needed. - # - # This postpones the initialization of the compressor until - # #compress is called the first time. - class LazyCompressor #:nodoc: - # Initializes a new LazyCompressor. - # - # The block should return a compressor when called, i.e. an object - # which responds to #compress. - def initialize(&block) - @block = block - end - - def compress(content) - compressor.compress(content) - end - - private - - def compressor - @compressor ||= (@block.call || NullCompressor.new) - end - end -end diff --git a/actionpack/lib/sprockets/helpers.rb b/actionpack/lib/sprockets/helpers.rb deleted file mode 100644 index fee48386e0..0000000000 --- a/actionpack/lib/sprockets/helpers.rb +++ /dev/null @@ -1,6 +0,0 @@ -module Sprockets - module Helpers - autoload :RailsHelper, "sprockets/helpers/rails_helper" - autoload :IsolatedHelper, "sprockets/helpers/isolated_helper" - end -end diff --git a/actionpack/lib/sprockets/helpers/isolated_helper.rb b/actionpack/lib/sprockets/helpers/isolated_helper.rb deleted file mode 100644 index 3adb928c45..0000000000 --- a/actionpack/lib/sprockets/helpers/isolated_helper.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Sprockets - module Helpers - module IsolatedHelper - def controller - nil - end - - def config - Rails.application.config.action_controller - end - end - end -end diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb deleted file mode 100644 index 243c2e5e50..0000000000 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ /dev/null @@ -1,182 +0,0 @@ -require "action_view" - -module Sprockets - module Helpers - module RailsHelper - extend ActiveSupport::Concern - include ActionView::Helpers::AssetTagHelper - - def asset_paths - @asset_paths ||= begin - paths = RailsHelper::AssetPaths.new(config, controller) - paths.asset_environment = asset_environment - paths.asset_digests = asset_digests - paths.compile_assets = compile_assets? - paths.digest_assets = digest_assets? - paths - end - end - - def javascript_include_tag(*sources) - options = sources.extract_options! - debug = options.key?(:debug) ? options.delete(:debug) : debug_assets? - body = options.key?(:body) ? options.delete(:body) : false - digest = options.key?(:digest) ? options.delete(:digest) : digest_assets? - - sources.collect do |source| - if debug && asset = asset_paths.asset_for(source, 'js') - asset.to_a.map { |dep| - super(dep.pathname.to_s, { :src => path_to_asset(dep, :ext => 'js', :body => true, :digest => digest) }.merge!(options)) - } - else - super(source.to_s, { :src => path_to_asset(source, :ext => 'js', :body => body, :digest => digest) }.merge!(options)) - end - end.flatten.uniq.join("\n").html_safe - end - - def stylesheet_link_tag(*sources) - options = sources.extract_options! - debug = options.key?(:debug) ? options.delete(:debug) : debug_assets? - body = options.key?(:body) ? options.delete(:body) : false - digest = options.key?(:digest) ? options.delete(:digest) : digest_assets? - - sources.collect do |source| - if debug && asset = asset_paths.asset_for(source, 'css') - asset.to_a.map { |dep| - super(dep.pathname.to_s, { :href => path_to_asset(dep, :ext => 'css', :body => true, :protocol => :request, :digest => digest) }.merge!(options)) - } - else - super(source.to_s, { :href => path_to_asset(source, :ext => 'css', :body => body, :protocol => :request, :digest => digest) }.merge!(options)) - end - end.flatten.uniq.join("\n").html_safe - end - - def asset_path(source, options = {}) - source = source.logical_path if source.respond_to?(:logical_path) - path = asset_paths.compute_public_path(source, asset_prefix, options.merge(:body => true)) - options[:body] ? "#{path}?body=1" : path - end - alias_method :path_to_asset, :asset_path # aliased to avoid conflicts with an asset_path named route - - def image_path(source) - path_to_asset(source) - end - alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route - - def font_path(source) - path_to_asset(source) - end - alias_method :path_to_font, :font_path # aliased to avoid conflicts with an font_path named route - - def javascript_path(source) - path_to_asset(source, :ext => 'js') - end - alias_method :path_to_javascript, :javascript_path # aliased to avoid conflicts with an javascript_path named route - - def stylesheet_path(source) - path_to_asset(source, :ext => 'css') - end - alias_method :path_to_stylesheet, :stylesheet_path # aliased to avoid conflicts with an stylesheet_path named route - - private - def debug_assets? - compile_assets? && (Rails.application.config.assets.debug || params[:debug_assets]) - rescue NameError - false - end - - # Override to specify an alternative prefix for asset path generation. - # When combined with a custom +asset_environment+, this can be used to - # implement themes that can take advantage of the asset pipeline. - # - # If you only want to change where the assets are mounted, refer to - # +config.assets.prefix+ instead. - def asset_prefix - Rails.application.config.assets.prefix - end - - def asset_digests - Rails.application.config.assets.digests - end - - def compile_assets? - Rails.application.config.assets.compile - end - - def digest_assets? - Rails.application.config.assets.digest - end - - # Override to specify an alternative asset environment for asset - # path generation. The environment should already have been mounted - # at the prefix returned by +asset_prefix+. - def asset_environment - Rails.application.assets - end - - class AssetPaths < ::ActionView::AssetPaths #:nodoc: - attr_accessor :asset_environment, :asset_prefix, :asset_digests, :compile_assets, :digest_assets - - class AssetNotPrecompiledError < StandardError; end - - def asset_for(source, ext) - source = source.to_s - return nil if is_uri?(source) - source = rewrite_extension(source, nil, ext) - asset_environment[source] - rescue Sprockets::FileOutsidePaths - nil - end - - def digest_for(logical_path) - if digest_assets && asset_digests && (digest = asset_digests[logical_path]) - return digest - end - - if compile_assets - if digest_assets && asset = asset_environment[logical_path] - return asset.digest_path - end - return logical_path - else - raise AssetNotPrecompiledError.new("#{logical_path} isn't precompiled") - end - end - - def rewrite_asset_path(source, dir, options = {}) - if source[0] == ?/ - source - else - if digest_assets && options[:digest] != false - source = digest_for(source) - end - source = File.join(dir, source) - source = "/#{source}" unless source =~ /^\// - source - end - end - - def rewrite_extension(source, dir, ext) - source_ext = File.extname(source)[1..-1] - - if !ext || ext == source_ext - source - elsif source_ext.blank? - "#{source}.#{ext}" - elsif File.exists?(source) || exact_match_present?(source) - source - else - "#{source}.#{ext}" - end - end - - def exact_match_present?(source) - pathname = asset_environment.resolve(source) - pathname.to_s =~ /#{Regexp.escape(source)}\Z/ - rescue Sprockets::FileNotFound - false - end - end - end - end -end diff --git a/actionpack/lib/sprockets/railtie.rb b/actionpack/lib/sprockets/railtie.rb deleted file mode 100644 index 44ddab0950..0000000000 --- a/actionpack/lib/sprockets/railtie.rb +++ /dev/null @@ -1,62 +0,0 @@ -require "action_controller/railtie" - -module Sprockets - autoload :Bootstrap, "sprockets/bootstrap" - autoload :Helpers, "sprockets/helpers" - autoload :Compressors, "sprockets/compressors" - autoload :LazyCompressor, "sprockets/compressors" - autoload :NullCompressor, "sprockets/compressors" - autoload :StaticCompiler, "sprockets/static_compiler" - - # TODO: Get rid of config.assets.enabled - class Railtie < ::Rails::Railtie - rake_tasks do - load "sprockets/assets.rake" - end - - initializer "sprockets.environment", :group => :all do |app| - config = app.config - next unless config.assets.enabled - - require 'sprockets' - - app.assets = Sprockets::Environment.new(app.root.to_s) do |env| - env.version = ::Rails.env + "-#{config.assets.version}" - - if config.assets.logger != false - env.logger = config.assets.logger || ::Rails.logger - end - - if config.assets.cache_store != false - env.cache = ActiveSupport::Cache.lookup_store(config.assets.cache_store) || ::Rails.cache - end - end - - if config.assets.manifest - path = File.join(config.assets.manifest, "manifest.yml") - else - path = File.join(Rails.public_path, config.assets.prefix, "manifest.yml") - end - - if File.exist?(path) - config.assets.digests = YAML.load_file(path) - end - - ActiveSupport.on_load(:action_view) do - include ::Sprockets::Helpers::RailsHelper - app.assets.context_class.instance_eval do - include ::Sprockets::Helpers::IsolatedHelper - include ::Sprockets::Helpers::RailsHelper - end - end - end - - # We need to configure this after initialization to ensure we collect - # paths from all engines. This hook is invoked exactly before routes - # are compiled, and so that other Railties have an opportunity to - # register compressors. - config.after_initialize do |app| - Sprockets::Bootstrap.new(app).run - end - end -end diff --git a/actionpack/lib/sprockets/static_compiler.rb b/actionpack/lib/sprockets/static_compiler.rb deleted file mode 100644 index 4341a27d5d..0000000000 --- a/actionpack/lib/sprockets/static_compiler.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'fileutils' - -module Sprockets - class StaticCompiler - attr_accessor :env, :target, :paths - - def initialize(env, target, paths, options = {}) - @env = env - @target = target - @paths = paths - @digest = options.key?(:digest) ? options.delete(:digest) : true - @manifest = options.key?(:manifest) ? options.delete(:manifest) : true - @manifest_path = options.delete(:manifest_path) || target - end - - def compile - manifest = {} - env.each_logical_path(paths) do |logical_path| - if asset = env.find_asset(logical_path) - digest_path = write_asset(asset) - manifest[asset.logical_path] = digest_path - manifest[aliased_path_for(asset.logical_path)] = digest_path - end - end - write_manifest(manifest) if @manifest - end - - def write_manifest(manifest) - FileUtils.mkdir_p(@manifest_path) - File.open("#{@manifest_path}/manifest.yml", 'wb') do |f| - YAML.dump(manifest, f) - end - end - - def write_asset(asset) - path_for(asset).tap do |path| - filename = File.join(target, path) - FileUtils.mkdir_p File.dirname(filename) - asset.write_to(filename) - asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/ - end - end - - def path_for(asset) - @digest ? asset.digest_path : asset.logical_path - end - - def aliased_path_for(logical_path) - if File.basename(logical_path).start_with?('index') - logical_path.sub(/\/index([^\/]+)$/, '\1') - else - logical_path.sub(/\.([^\/]+)$/, '/index.\1') - end - end - end -end diff --git a/actionpack/test/template/compressors_test.rb b/actionpack/test/template/compressors_test.rb deleted file mode 100644 index a273f15bd7..0000000000 --- a/actionpack/test/template/compressors_test.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'abstract_unit' -require 'sprockets/compressors' - -class CompressorsTest < ActiveSupport::TestCase - def test_register_css_compressor - Sprockets::Compressors.register_css_compressor(:null, Sprockets::NullCompressor) - compressor = Sprockets::Compressors.registered_css_compressor(:null) - assert_kind_of Sprockets::NullCompressor, compressor - end - - def test_register_js_compressor - Sprockets::Compressors.register_js_compressor(:uglifier, 'Uglifier', :require => 'uglifier') - compressor = Sprockets::Compressors.registered_js_compressor(:uglifier) - assert_kind_of Uglifier, compressor - end - - def test_register_default_css_compressor - Sprockets::Compressors.register_css_compressor(:null, Sprockets::NullCompressor, :default => true) - compressor = Sprockets::Compressors.registered_css_compressor(:default) - assert_kind_of Sprockets::NullCompressor, compressor - end - - def test_register_default_js_compressor - Sprockets::Compressors.register_js_compressor(:null, Sprockets::NullCompressor, :default => true) - compressor = Sprockets::Compressors.registered_js_compressor(:default) - assert_kind_of Sprockets::NullCompressor, compressor - end -end diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb deleted file mode 100644 index 1ad9bcab5a..0000000000 --- a/actionpack/test/template/sprockets_helper_test.rb +++ /dev/null @@ -1,392 +0,0 @@ -require 'abstract_unit' -require 'sprockets' -require 'sprockets/helpers/rails_helper' -require 'mocha/setup' - -class SprocketsHelperTest < ActionView::TestCase - include Sprockets::Helpers::RailsHelper - - attr_accessor :assets - - class MockRequest - def protocol() 'http://' end - def ssl?() false end - def host_with_port() 'localhost' end - end - - def setup - super - - @controller = BasicController.new - @controller.request = MockRequest.new - - @assets = Sprockets::Environment.new - @assets.append_path(FIXTURES.join("sprockets/app/javascripts")) - @assets.append_path(FIXTURES.join("sprockets/app/stylesheets")) - @assets.append_path(FIXTURES.join("sprockets/app/images")) - @assets.append_path(FIXTURES.join("sprockets/app/fonts")) - - application = Struct.new(:config, :assets).new(config, @assets) - Rails.stubs(:application).returns(application) - @config = config - @config.perform_caching = true - @config.assets.digest = true - @config.assets.compile = true - end - - def url_for(*args) - "http://www.example.com" - end - - def config - @controller ? @controller.config : @config - end - - def compute_host(source, request, options = {}) - raise "Should never get here" - end - - test "asset_path" do - assert_match %r{/assets/logo-[0-9a-f]+.png}, - asset_path("logo.png") - assert_match %r{/assets/logo-[0-9a-f]+.png}, - asset_path("logo.png", :digest => true) - assert_match %r{/assets/logo.png}, - asset_path("logo.png", :digest => false) - end - - test "custom_asset_path" do - @config.assets.prefix = '/s' - assert_match %r{/s/logo-[0-9a-f]+.png}, - asset_path("logo.png") - assert_match %r{/s/logo-[0-9a-f]+.png}, - asset_path("logo.png", :digest => true) - assert_match %r{/s/logo.png}, - asset_path("logo.png", :digest => false) - end - - test "asset_path with root relative assets" do - assert_equal "/images/logo", - asset_path("/images/logo") - assert_equal "/images/logo.gif", - asset_path("/images/logo.gif") - - assert_equal "/dir/audio", - asset_path("/dir/audio") - end - - test "asset_path with absolute urls" do - assert_equal "http://www.example.com/video/play", - asset_path("http://www.example.com/video/play") - assert_equal "http://www.example.com/video/play.mp4", - asset_path("http://www.example.com/video/play.mp4") - end - - test "with a simple asset host the url should default to protocol relative" do - @controller.config.default_asset_host_protocol = :relative - @controller.config.asset_host = "assets-%d.example.com" - assert_match %r{^//assets-\d.example.com/assets/logo-[0-9a-f]+.png}, - asset_path("logo.png") - end - - test "with a simple asset host the url can be changed to use the request protocol" do - @controller.config.asset_host = "assets-%d.example.com" - @controller.config.default_asset_host_protocol = :request - assert_match %r{http://assets-\d.example.com/assets/logo-[0-9a-f]+.png}, - asset_path("logo.png") - end - - test "With a proc asset host that returns no protocol the url should be protocol relative" do - @controller.config.default_asset_host_protocol = :relative - @controller.config.asset_host = Proc.new do |asset| - "assets-999.example.com" - end - assert_match %r{^//assets-999.example.com/assets/logo-[0-9a-f]+.png}, - asset_path("logo.png") - end - - test "with a proc asset host that returns a protocol the url use it" do - @controller.config.asset_host = Proc.new do |asset| - "http://assets-999.example.com" - end - assert_match %r{http://assets-999.example.com/assets/logo-[0-9a-f]+.png}, - asset_path("logo.png") - end - - test "stylesheets served with a controller in scope can access the request" do - config.asset_host = Proc.new do |asset, request| - assert_not_nil request - "http://assets-666.example.com" - end - assert_match %r{http://assets-666.example.com/assets/logo-[0-9a-f]+.png}, - asset_path("logo.png") - end - - test "stylesheets served without a controller in scope cannot access the request" do - @controller = nil - @config.asset_host = Proc.new do |asset, request| - fail "This should not have been called." - end - assert_raises ActionController::RoutingError do - asset_path("logo.png") - end - @config.asset_host = method :compute_host - assert_raises ActionController::RoutingError do - asset_path("logo.png") - end - end - - test "image_tag" do - assert_dom_equal 'Xml', image_tag("xml.png") - end - - test "image_path" do - assert_match %r{/assets/logo-[0-9a-f]+.png}, - image_path("logo.png") - - assert_match %r{/assets/logo-[0-9a-f]+.png}, - path_to_image("logo.png") - end - - test "font_path" do - assert_match %r{/assets/font-[0-9a-f]+.ttf}, - font_path("font.ttf") - - assert_match %r{/assets/font-[0-9a-f]+.ttf}, - path_to_font("font.ttf") - end - - test "javascript_path" do - assert_match %r{/assets/application-[0-9a-f]+.js}, - javascript_path("application") - - assert_match %r{/assets/application-[0-9a-f]+.js}, - javascript_path("application.js") - - assert_match %r{/assets/application-[0-9a-f]+.js}, - path_to_javascript("application.js") - end - - test "stylesheet_path" do - assert_match %r{/assets/application-[0-9a-f]+.css}, - stylesheet_path("application") - - assert_match %r{/assets/application-[0-9a-f]+.css}, - stylesheet_path("application.css") - - assert_match %r{/assets/application-[0-9a-f]+.css}, - path_to_stylesheet("application.css") - end - - test "stylesheets served without a controller in do not use asset hosts when the default protocol is :request" do - @controller = nil - @config.asset_host = "assets-%d.example.com" - @config.default_asset_host_protocol = :request - @config.perform_caching = true - - assert_match %r{/assets/logo-[0-9a-f]+.png}, - asset_path("logo.png") - end - - test "asset path with relative url root" do - @controller.config.relative_url_root = "/collaboration/hieraki" - assert_equal "/collaboration/hieraki/images/logo.gif", - asset_path("/images/logo.gif") - end - - test "asset path with relative url root when controller isn't present but relative_url_root is" do - @controller = nil - @config.relative_url_root = "/collaboration/hieraki" - assert_equal "/collaboration/hieraki/images/logo.gif", - asset_path("/images/logo.gif") - end - - test "font path through asset_path" do - assert_match %r{/assets/font-[0-9a-f]+.ttf}, - asset_path('font.ttf') - - assert_match %r{/assets/dir/font-[0-9a-f]+.ttf}, - asset_path("dir/font.ttf") - - assert_equal "http://www.example.com/fonts/font.ttf", - asset_path("http://www.example.com/fonts/font.ttf") - end - - test "javascript path through asset_path" do - assert_match %r{/assets/application-[0-9a-f]+.js}, - asset_path(:application, :ext => "js") - - assert_match %r{/assets/xmlhr-[0-9a-f]+.js}, - asset_path("xmlhr", :ext => "js") - assert_match %r{/assets/dir/xmlhr-[0-9a-f]+.js}, - asset_path("dir/xmlhr.js", :ext => "js") - - assert_equal "/dir/xmlhr.js", - asset_path("/dir/xmlhr", :ext => "js") - - assert_equal "http://www.example.com/js/xmlhr", - asset_path("http://www.example.com/js/xmlhr", :ext => "js") - assert_equal "http://www.example.com/js/xmlhr.js", - asset_path("http://www.example.com/js/xmlhr.js", :ext => "js") - end - - test "javascript include tag" do - assert_match %r{}, - javascript_include_tag(:application) - assert_match %r{}, - javascript_include_tag(:application, :digest => true) - assert_match %r{}, - javascript_include_tag(:application, :digest => false) - - assert_match %r{}, - javascript_include_tag("xmlhr") - assert_match %r{}, - javascript_include_tag("xmlhr.js") - assert_equal '', - javascript_include_tag("http://www.example.com/xmlhr") - - assert_match %r{\n}, - javascript_include_tag("xmlhr", "extra") - - assert_match %r{\n}, - javascript_include_tag(:application, :debug => true) - - assert_match %r{}, - javascript_include_tag('jquery.plugin', :digest => false) - - assert_match %r{\A\Z}, - javascript_include_tag("xmlhr", "xmlhr") - - assert_match %r{\A\Z}, - javascript_include_tag("foo.min") - - @config.assets.compile = true - @config.assets.debug = true - assert_match %r{}, - javascript_include_tag('/javascripts/application') - assert_match %r{\n}, - javascript_include_tag(:application) - assert_match %r{\n\n}, - javascript_include_tag(:application, :extra) - end - - test "precompiled assets with an extension when no JS runtime is available" do - @config.assets.compile = false - @config.assets.digests = {'foo.min.js' => 'foo.min-f00.js'} - Sprockets::Index.any_instance.stubs(:build_asset).raises - assert_nothing_raised { javascript_include_tag('foo.min') } - end - - test "assets that exist on filesystem don't need to go through Sprockets" do - @config.assets.digest = false - @config.assets.debug = true - - Rails.application.assets.expects(:resolve).never - - asset_paths.asset_for(FIXTURES.join("sprockets/app/javascripts/foo.min.js"), 'min') - end - - test "stylesheet path through asset_path" do - assert_match %r{/assets/application-[0-9a-f]+.css}, asset_path(:application, :ext => "css") - - assert_match %r{/assets/style-[0-9a-f]+.css}, asset_path("style", :ext => "css") - assert_match %r{/assets/dir/style-[0-9a-f]+.css}, asset_path("dir/style.css", :ext => "css") - assert_equal "/dir/style.css", asset_path("/dir/style.css", :ext => "css") - - assert_equal "http://www.example.com/css/style", - asset_path("http://www.example.com/css/style", :ext => "css") - assert_equal "http://www.example.com/css/style.css", - asset_path("http://www.example.com/css/style.css", :ext => "css") - end - - test "stylesheet link tag" do - assert_match %r{}, - stylesheet_link_tag(:application) - assert_match %r{}, - stylesheet_link_tag(:application, :digest => true) - assert_match %r{}, - stylesheet_link_tag(:application, :digest => false) - - assert_match %r{}, - stylesheet_link_tag("style") - assert_match %r{}, - stylesheet_link_tag("style.css") - - assert_equal '', - stylesheet_link_tag("http://www.example.com/style.css") - assert_match %r{}, - stylesheet_link_tag("style", :media => "all") - assert_match %r{}, - stylesheet_link_tag("style", :media => "print") - - assert_match %r{\n}, - stylesheet_link_tag("style", "extra") - - assert_match %r{\n}, - stylesheet_link_tag(:application, :debug => true) - - assert_match %r{\A\Z}, - stylesheet_link_tag("style", "style") - - assert_match %r{\A\Z}, - stylesheet_link_tag("style.ext") - - assert_match %r{\A\Z}, - stylesheet_link_tag("style.min") - - @config.assets.compile = true - @config.assets.debug = true - assert_match %r{}, - stylesheet_link_tag('/stylesheets/application') - - assert_match %r{\n}, - stylesheet_link_tag(:application) - - assert_match %r{\n\n}, - stylesheet_link_tag(:application, :extra) - - assert_match %r{\n}, - stylesheet_link_tag(:application, :media => "print") - end - - test "alternate asset prefix" do - stubs(:asset_prefix).returns("/themes/test") - assert_match %r{/themes/test/style-[0-9a-f]+.css}, asset_path("style", :ext => "css") - end - - test "alternate asset environment" do - assets = Sprockets::Environment.new - assets.append_path(FIXTURES.join("sprockets/alternate/stylesheets")) - stubs(:asset_environment).returns(assets) - assert_match %r{/assets/style-[0-9a-f]+.css}, asset_path("style", :ext => "css") - end - - test "alternate hash based on environment" do - assets = Sprockets::Environment.new - assets.version = 'development' - assets.append_path(FIXTURES.join("sprockets/alternate/stylesheets")) - stubs(:asset_environment).returns(assets) - dev_path = asset_path("style", :ext => "css") - - assets.version = 'production' - prod_path = asset_path("style", :ext => "css") - - assert_not_equal prod_path, dev_path - end - - test "precedence of `config.digest = false` over manifest.yml asset digests" do - Rails.application.config.assets.digests = {'logo.png' => 'logo-d1g3st.png'} - @config.assets.digest = false - - assert_equal '/assets/logo.png', - asset_path("logo.png") - end - - test "`config.digest = false` works with `config.compile = false`" do - @config.assets.digest = false - @config.assets.compile = false - - assert_equal '/assets/logo.png', - asset_path("logo.png") - end -end diff --git a/actionpack/test/template/sprockets_helper_with_routes_test.rb b/actionpack/test/template/sprockets_helper_with_routes_test.rb deleted file mode 100644 index bc253ea0fd..0000000000 --- a/actionpack/test/template/sprockets_helper_with_routes_test.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'abstract_unit' -require 'sprockets' -require 'sprockets/helpers/rails_helper' -require 'mocha/setup' - -class SprocketsHelperWithRoutesTest < ActionView::TestCase - include Sprockets::Helpers::RailsHelper - - # Let's bring in some named routes to test namespace conflicts with potential *_paths. - # We have to do this after we bring in the Sprockets RailsHelper so if there are conflicts, - # they'll fail in the way we expect in a real live Rails app. - routes = ActionDispatch::Routing::RouteSet.new - routes.draw do - resources :assets - end - include routes.url_helpers - - def setup - super - @controller = BasicController.new - - @assets = Sprockets::Environment.new - @assets.append_path(FIXTURES.join("sprockets/app/javascripts")) - @assets.append_path(FIXTURES.join("sprockets/app/stylesheets")) - @assets.append_path(FIXTURES.join("sprockets/app/images")) - - application = Struct.new(:config, :assets).new(config, @assets) - Rails.stubs(:application).returns(application) - @config = config - @config.perform_caching = true - @config.assets.digest = true - @config.assets.compile = true - end - - test "namespace conflicts on a named route called asset_path" do - # Testing this for sanity - asset_path is now a named route! - assert_match asset_path('test_asset'), '/assets/test_asset' - - assert_match %r{/assets/logo-[0-9a-f]+.png}, - path_to_asset("logo.png") - assert_match %r{/assets/logo-[0-9a-f]+.png}, - path_to_asset("logo.png", :digest => true) - assert_match %r{/assets/logo.png}, - path_to_asset("logo.png", :digest => false) - end - - test "javascript_include_tag with a named_route named asset_path" do - assert_match %r{}, - javascript_include_tag(:application) - end - - test "stylesheet_link_tag with a named_route named asset_path" do - assert_match %r{}, - stylesheet_link_tag(:application) - end - -end diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb deleted file mode 100644 index adec9533a9..0000000000 --- a/railties/test/application/assets_test.rb +++ /dev/null @@ -1,556 +0,0 @@ -# -*- coding: utf-8 -*- -require 'isolation/abstract_unit' -require 'active_support/core_ext/kernel/reporting' -require 'rack/test' -require 'yaml' - -module ApplicationTests - class AssetsTest < Test::Unit::TestCase - include ActiveSupport::Testing::Isolation - include Rack::Test::Methods - - def setup - build_app(:initializers => true) - boot_rails - end - - def teardown - teardown_app - end - - def precompile! - quietly do - Dir.chdir(app_path){ `bundle exec rake assets:precompile` } - end - end - - test "assets routes have higher priority" do - 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 - match '*path', :to => lambda { |env| [200, { "Content-Type" => "text/html" }, "Not an asset"] } - end - RUBY - - require "#{app_path}/config/environment" - - get "/assets/demo.js" - assert_equal 'a = "/assets/rails.png";', last_response.body.strip - end - - test "assets do not require compressors until it is used" do - app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();" - add_to_env_config "production", "config.assets.compile = true" - - ENV["RAILS_ENV"] = "production" - require "#{app_path}/config/environment" - - assert !defined?(Uglifier) - get "/assets/demo.js" - assert_match "alert()", last_response.body - assert defined?(Uglifier) - end - - test "precompile creates the file, gives it the original asset's content and run in production as default" do - app_file "app/assets/javascripts/application.js", "alert();" - app_file "app/assets/javascripts/foo/application.js", "alert();" - - ENV["RAILS_ENV"] = nil - precompile! - - 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) - end - end - - test "precompile application.js and application.css and all other non JS/CSS files" do - app_file "app/assets/javascripts/application.js", "alert();" - app_file "app/assets/stylesheets/application.css", "body{}" - - app_file "app/assets/javascripts/someapplication.js", "alert();" - app_file "app/assets/stylesheets/someapplication.css", "body{}" - - app_file "app/assets/javascripts/something.min.js", "alert();" - app_file "app/assets/stylesheets/something.min.css", "body{}" - - app_file "app/assets/javascripts/something.else.js.erb", "alert();" - app_file "app/assets/stylesheets/something.else.css.erb", "body{}" - - images_should_compile = ["a.png", "happyface.png", "happy_face.png", "happy.face.png", - "happy-face.png", "happy.happy_face.png", "happy_happy.face.png", - "happy.happy.face.png", "-happy.png", "-happy.face.png", - "_happy.face.png", "_happy.png"] - - images_should_compile.each do |filename| - app_file "app/assets/images/#{filename}", "happy" - end - - precompile! - - images_should_compile.each do |filename| - assert_file_exists "#{app_path}/public/assets/#{filename}" - end - - assert_file_exists("#{app_path}/public/assets/application.js") - assert_file_exists("#{app_path}/public/assets/application.css") - - assert_no_file_exists("#{app_path}/public/assets/someapplication.js") - assert_no_file_exists("#{app_path}/public/assets/someapplication.css") - - assert_no_file_exists("#{app_path}/public/assets/something.min.js") - assert_no_file_exists("#{app_path}/public/assets/something.min.css") - - assert_no_file_exists("#{app_path}/public/assets/something.else.js") - assert_no_file_exists("#{app_path}/public/assets/something.else.css") - end - - def assert_file_exists(filename) - assert File.exists?(filename), "missing #{filename}" - end - - def assert_no_file_exists(filename) - assert !File.exists?(filename), "#{filename} does exist" - end - - test "precompile something.js for directory containing index file" do - add_to_config "config.assets.precompile = [ 'something.js' ]" - app_file "app/assets/javascripts/something/index.js.erb", "alert();" - - precompile! - assert File.exists?("#{app_path}/public/assets/something.js") - - assets = YAML.load_file("#{app_path}/public/assets/manifest.yml") - assert_not_nil assets['something/index.js'], "Expected something/index.js among #{assets.keys.inspect}" - assert_not_nil assets['something.js'], "Expected something.js among #{assets.keys.inspect}" - end - - test "precompile something/index.js for directory containing index file" do - add_to_config "config.assets.precompile = [ 'something/index.js' ]" - app_file "app/assets/javascripts/something/index.js.erb", "alert();" - - precompile! - assert File.exists?("#{app_path}/public/assets/something/index.js") - - assets = YAML.load_file("#{app_path}/public/assets/manifest.yml") - assert_not_nil assets['something/index.js'], "Expected something/index.js among #{assets.keys.inspect}" - assert_not_nil assets['something.js'], "Expected something.js among #{assets.keys.inspect}" - end - - test "asset pipeline should use a Sprockets::Index when config.assets.digest is true" do - add_to_config "config.assets.digest = true" - add_to_config "config.action_controller.perform_caching = false" - - ENV["RAILS_ENV"] = "production" - require "#{app_path}/config/environment" - - assert_equal Sprockets::Index, Rails.application.assets.class - end - - 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();" - # digest is default in false, we must enable it for test environment - add_to_config "config.assets.digest = true" - - precompile! - manifest = "#{app_path}/public/assets/manifest.yml" - - assets = YAML.load_file(manifest) - assert_match(/application-([0-z]+)\.js/, assets["application.js"]) - assert_match(/application-([0-z]+)\.css/, assets["application.css"]) - end - - test "precompile creates a manifest file in a custom path 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();" - # digest is default in false, we must enable it for test environment - add_to_config "config.assets.digest = true" - add_to_config "config.assets.manifest = '#{app_path}/shared'" - - precompile! - manifest = "#{app_path}/shared/manifest.yml" - - assets = YAML.load_file(manifest) - assert_match(/application-([0-z]+)\.js/, assets["application.js"]) - assert_match(/application-([0-z]+)\.css/, assets["application.css"]) - end - - test "the manifest file should be saved by default in the same assets folder" do - app_file "app/assets/javascripts/application.js", "alert();" - # digest is default in false, we must enable it for test environment - add_to_config "config.assets.digest = true" - add_to_config "config.assets.prefix = '/x'" - - precompile! - - manifest = "#{app_path}/public/x/manifest.yml" - assets = YAML.load_file(manifest) - assert_match(/application-([0-z]+)\.js/, assets["application.js"]) - end - - test "precompile does not append asset digests when config.assets.digest is false" do - app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" - app_file "app/assets/javascripts/application.js", "alert();" - add_to_config "config.assets.digest = false" - - precompile! - - assert File.exists?("#{app_path}/public/assets/application.js") - assert File.exists?("#{app_path}/public/assets/application.css") - - manifest = "#{app_path}/public/assets/manifest.yml" - - assets = YAML.load_file(manifest) - assert_equal "application.js", assets["application.js"] - assert_equal "application.css", assets["application.css"] - end - - test "assets do not require any assets group gem when manifest file is present" do - app_file "app/assets/javascripts/application.js", "alert();" - add_to_env_config "production", "config.serve_static_assets = true" - - ENV["RAILS_ENV"] = "production" - precompile! - - manifest = "#{app_path}/public/assets/manifest.yml" - assets = YAML.load_file(manifest) - asset_path = assets["application.js"] - - require "#{app_path}/config/environment" - - # Checking if Uglifier is defined we can know if Sprockets was reached or not - assert !defined?(Uglifier) - get "/assets/#{asset_path}" - assert_match "alert()", last_response.body - assert !defined?(Uglifier) - end - - 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/routes.rb", <<-RUBY - AppTemplate::Application.routes.draw do - match '/posts', :to => "posts#index" - end - RUBY - - ENV["RAILS_ENV"] = "production" - precompile! - - # Create file after of precompile - app_file "app/assets/javascripts/app.js", "alert();" - - require "#{app_path}/config/environment" - class ::PostsController < ActionController::Base - def show_detailed_exceptions?() true end - end - - get '/posts' - assert_match(/AssetNotPrecompiledError/, last_response.body) - assert_match(/app.js isn't precompiled/, last_response.body) - end - - test "assets raise AssetNotPrecompiledError when manifest file is present and requested file isn't precompiled if digest is disabled" do - app_file "app/views/posts/index.html.erb", "<%= javascript_include_tag 'app' %>" - add_to_config "config.assets.compile = false" - add_to_config "config.assets.digest = false" - - app_file "config/routes.rb", <<-RUBY - AppTemplate::Application.routes.draw do - match '/posts', :to => "posts#index" - end - RUBY - - ENV["RAILS_ENV"] = "production" - precompile! - - # Create file after of precompile - app_file "app/assets/javascripts/app.js", "alert();" - - require "#{app_path}/config/environment" - class ::PostsController < ActionController::Base - def show_detailed_exceptions?() true end - end - - get '/posts' - assert_match(/AssetNotPrecompiledError/, last_response.body) - assert_match(/app.js isn't precompiled/, last_response.body) - end - - test "precompile properly refers files referenced with asset_path and and run in the provided RAILS_ENV" do - app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" - # digest is default in false, we must enable it for test environment - add_to_env_config "test", "config.assets.digest = true" - - quietly do - Dir.chdir(app_path){ `bundle exec rake assets:precompile RAILS_ENV=test` } - end - file = Dir["#{app_path}/public/assets/application.css"].first - assert_match(/\/assets\/rails\.png/, File.read(file)) - file = Dir["#{app_path}/public/assets/application-*.css"].first - assert_match(/\/assets\/rails-([0-z]+)\.png/, File.read(file)) - end - - test "precompile shouldn't use the digests present in manifest.yml" do - app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" - - ENV["RAILS_ENV"] = "production" - precompile! - - manifest = "#{app_path}/public/assets/manifest.yml" - assets = YAML.load_file(manifest) - asset_path = assets["application.css"] - - app_file "app/assets/images/rails.png", "image changed" - - precompile! - assets = YAML.load_file(manifest) - - assert_not_equal asset_path, assets["application.css"] - end - - test "precompile appends the md5 hash to files referenced with asset_path and run in production as default even using RAILS_GROUPS=assets" do - app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" - add_to_config "config.assets.compile = true" - - ENV["RAILS_ENV"] = nil - quietly do - Dir.chdir(app_path){ `bundle exec rake assets:precompile RAILS_GROUPS=assets` } - end - file = Dir["#{app_path}/public/assets/application-*.css"].first - assert_match(/\/assets\/rails-([0-z]+)\.png/, File.read(file)) - end - - test "precompile should handle utf8 filenames" do - filename = "レイルズ.png" - app_file "app/assets/images/#{filename}", "not a image really" - add_to_config "config.assets.precompile = [ /\.png$/, /application.(css|js)$/ ]" - - precompile! - require "#{app_path}/config/environment" - - get "/assets/#{URI.parser.escape(filename)}" - assert_match "not a image really", last_response.body - assert File.exists?("#{app_path}/public/assets/#{filename}") - end - - test "assets are cleaned up properly" do - app_file "public/assets/application.js", "alert();" - app_file "public/assets/application.css", "a { color: green; }" - app_file "public/assets/subdir/broken.png", "not really an image file" - - quietly do - Dir.chdir(app_path){ `bundle exec rake assets:clean` } - end - - files = Dir["#{app_path}/public/assets/**/*", "#{app_path}/tmp/cache/*"] - 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 %>();" - - app_file "config/routes.rb", <<-RUBY - AppTemplate::Application.routes.draw do - match '/omg', :to => "omg#index" - end - RUBY - - require "#{app_path}/config/environment" - - class ::OmgController < ActionController::Base - def index - flash[:cool_story] = true - render :text => "ok" - end - end - - get "/omg" - assert_equal 'ok', last_response.body - - get "/assets/demo.js" - assert_match "alert()", last_response.body - assert_equal nil, last_response.headers["Set-Cookie"] - end - - test "files in any assets/ directories are not added to Sprockets" do - %w[app lib vendor].each do |dir| - app_file "#{dir}/assets/#{dir}_test.erb", "testing" - end - - app_file "app/assets/javascripts/demo.js", "alert();" - - require "#{app_path}/config/environment" - - get "/assets/demo.js" - assert_match "alert();", last_response.body - assert_equal 200, last_response.status - end - - test "assets are concatenated when debug is off and compile is off either if debug_assets param is provided" do - app_with_assets_in_view - - # config.assets.debug and config.assets.compile are false for production environment - ENV["RAILS_ENV"] = "production" - precompile! - - require "#{app_path}/config/environment" - - class ::PostsController < ActionController::Base ; end - - # the debug_assets params isn't used if compile is off - get '/posts?debug_assets=true' - assert_match(/