Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2581 from guilleiguaran/debug-assets-in-dev

Debug assets by default in development and test environments
  • Loading branch information...
commit c09dbf20624010f29c72081d9f455f74489caf39 1 parent 1b819d3
@spastorino spastorino authored
View
4 actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -70,8 +70,8 @@ def asset_path(source, default_ext = nil, body = false, protocol = nil)
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
View
28 actionpack/test/template/sprockets_helper_test.rb
@@ -144,6 +144,8 @@ def url_for(*args)
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)
@@ -154,11 +156,17 @@ def url_for(*args)
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
@@ -175,6 +183,8 @@ def url_for(*args)
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)
@@ -190,11 +200,17 @@ def url_for(*args)
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
Please sign in to comment.
Something went wrong with that request. Please try again.