# frozen_string_literal: true require "isolation/abstract_unit" require "rack/test" module ApplicationTests class AssetDebuggingTest < ActiveSupport::TestCase include ActiveSupport::Testing::Isolation include Rack::Test::Methods def setup build_app(initializers: true) app_file "app/assets/javascripts/application.js", "//= require_tree ." app_file "app/assets/javascripts/xmlhr.js", "function f1() { alert(); }" app_file "app/views/posts/index.html.erb", "<%= javascript_include_tag 'application' %>" app_file "config/routes.rb", <<-RUBY Rails.application.routes.draw do get '/posts', to: "posts#index" end RUBY app_file "app/controllers/posts_controller.rb", <<-RUBY class PostsController < ActionController::Base end RUBY ENV["RAILS_ENV"] = "production" end def teardown teardown_app end test "assets are concatenated when debug is off and compile is off either if debug_assets param is provided" do # config.assets.debug and config.assets.compile are false for production environment ENV["RAILS_ENV"] = "production" rails "assets:precompile", "--trace" # Load app env app "production" class ::PostsController < ActionController::Base ; end # the debug_assets params isn't used if compile is off get "/posts?debug_assets=true" assert_match(/