mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #2581 from guilleiguaran/debug-assets-in-dev
Debug assets by default in development and test environments
This commit is contained in:
commit
8bd76aa50e
2 changed files with 25 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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\?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)
|
||||
|
||||
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>},
|
||||
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)
|
||||
|
||||
assert_match %r{<script src="/assets/application-[0-9a-f]+.js\" type="text/javascript"></script>},
|
||||
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{<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
|
||||
|
|
Loading…
Reference in a new issue