aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/sprockets/helpers/rails_helper.rb4
-rw-r--r--actionpack/test/template/sprockets_helper_test.rb28
2 files changed, 24 insertions, 8 deletions
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{<script src="/assets/application-[0-9a-f]+.js" type="text/javascript"></script>},
javascript_include_tag(:application)
@@ -151,11 +153,17 @@ class SprocketsHelperTest < ActionView::TestCase
assert_equal '<script src="http://www.example.com/xmlhr" type="text/javascript"></script>',
javascript_include_tag("http://www.example.com/xmlhr")
+ assert_match %r{<script src=\"/assets/xmlhr-[0-9a-f]+.js" type=\"text/javascript\"></script>\n<script src=\"/assets/extra-[0-9a-f]+.js" type=\"text/javascript\"></script>},
+ javascript_include_tag("xmlhr", "extra")
+
+ Rails.env.stubs(:test?).returns(true)
+
assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js\?body=1" type="text/javascript"></script>\n<script src="/assets/application-[0-9a-f]+.js\?body=1" type="text/javascript"></script>},
- javascript_include_tag(:application, :debug => true)
+ javascript_include_tag(:application)
+
+ assert_match %r{<script src="/assets/application-[0-9a-f]+.js\" type="text/javascript"></script>},
+ javascript_include_tag(:application, :debug => false)
- assert_match %r{<script src=\"/assets/xmlhr-[0-9a-f]+.js\" type=\"text/javascript\"></script>\n<script src=\"/assets/extra-[0-9a-f]+.js\" type=\"text/javascript\"></script>},
- javascript_include_tag("xmlhr", "extra")
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{<link href="/assets/application-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />},
stylesheet_link_tag(:application)
@@ -187,11 +197,17 @@ class SprocketsHelperTest < ActionView::TestCase
assert_match %r{<link href="/assets/style-[0-9a-f]+.css" media="print" rel="stylesheet" type="text/css" />},
stylesheet_link_tag("style", :media => "print")
- assert_match %r{<link href="/assets/style-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/application-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />},
- stylesheet_link_tag(:application, :debug => true)
-
assert_match %r{<link href="/assets/style-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/extra-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />},
stylesheet_link_tag("style", "extra")
+
+ Rails.env.stubs(:test?).returns(true)
+
+ assert_match %r{<link href="/assets/style-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/application-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />},
+ stylesheet_link_tag(:application)
+
+ assert_match %r{<link href="/assets/application-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />},
+ stylesheet_link_tag(:application, :debug => false)
+
end
test "alternate asset prefix" do