diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index ec3d36d5ad..a65c5992ca 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -70,8 +70,8 @@ module Sprockets private def debug_assets? - params[:debug_assets] == '1' || - params[:debug_assets] == 'true' + Rails.env.development? || Rails.env.test? || + params[:debug_assets] == '1' || params[:debug_assets] == 'true' rescue NoMethodError false end diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index dfa635335e..d303acad0f 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -141,6 +141,8 @@ class SprocketsHelperTest < ActionView::TestCase end test "javascript include tag" do + Rails.env.stubs(:test?).returns(false) + assert_match %r{}, javascript_include_tag(:application) @@ -151,11 +153,17 @@ class SprocketsHelperTest < ActionView::TestCase assert_equal '', javascript_include_tag("http://www.example.com/xmlhr") - assert_match %r{\n}, - javascript_include_tag(:application, :debug => true) - - assert_match %r{\n}, + assert_match %r{\n}, javascript_include_tag("xmlhr", "extra") + + Rails.env.stubs(:test?).returns(true) + + assert_match %r{\n}, + javascript_include_tag(:application) + + assert_match %r{}, + javascript_include_tag(:application, :debug => false) + end test "stylesheet path" do @@ -172,6 +180,8 @@ class SprocketsHelperTest < ActionView::TestCase end test "stylesheet link tag" do + Rails.env.stubs(:test?).returns(false) + assert_match %r{}, stylesheet_link_tag(:application) @@ -187,11 +197,17 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{}, stylesheet_link_tag("style", :media => "print") - assert_match %r{\n}, - stylesheet_link_tag(:application, :debug => true) - assert_match %r{\n}, stylesheet_link_tag("style", "extra") + + Rails.env.stubs(:test?).returns(true) + + assert_match %r{\n}, + stylesheet_link_tag(:application) + + assert_match %r{}, + stylesheet_link_tag(:application, :debug => false) + end test "alternate asset prefix" do