Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Debug assets by default in development and test environments #2581

Merged
merged 1 commit into from

3 participants

@spastorino spastorino merged commit 8bd76aa into rails:master
@spohlenz

#2411 seems like a more flexible and simpler version of this feature.

I'd prefer to see that one merged in over this, with the default for config.assets.debug set to true in development mode.

@spastorino
Owner

@spohlenz agree, commented on #2411

@tenderlove tenderlove referenced this pull request from a commit
@tenderlove tenderlove Merge branch '3-1-stable' into 3-1-0
* 3-1-stable: (21 commits)
  Added a test to check for correct behaviour with no options in add_index command recorder
  Using .try to test for the existence of a method option in a nil-resistent manner. Inlined the determination of the options hash for reversing using a ternary operator. Shortens the method in a way that keeps the code neat
  Neatened up the invert_add_index method as per suggeston
  Simple fix for correctly inverting an add_index migration when a name has been provided
  Merge pull request #2524 from JonathonMA/fix_ecd37084b28a05f05251
  Fix Sprockets rewrite_asset_path
  Merge pull request #2620 from cesario/3-1-0
  Fix sprockets warnings
  Use typewriter styling on url_for in documentation
  Merge pull request #2609 from guilleiguaran/bump-sprockets-beta14
  remove extra space since comment_if already returns the space. (cherry picked from commit 5e73a2f)
  Merge pull request #2596 from dharmatech/patch-1
  Merge pull request #2595 from smartinez87/assets-guide
  Merge pull request #2597 from dharmatech/patch-2
  Merge pull request #2604 from vijaydev/params_wrapper_docs
  Merge pull request #2602 from ernie/fix_predicate_builder_primary_key_assumption
  Merge pull request #2603 from vijaydev/guides
  Merge pull request #2581 from guilleiguaran/debug-assets-in-dev
  Revert "Deprecate the use of non-public methods by Module#delegate"
  mailer guide: fixes indentation, and use fixed width fonts wherever necessary
  ...
1f1d4aa
@ttosch ttosch referenced this pull request from a commit
@tenderlove tenderlove Merge branch '3-1-stable' into 3-1-0
* 3-1-stable: (21 commits)
  Added a test to check for correct behaviour with no options in add_index command recorder
  Using .try to test for the existence of a method option in a nil-resistent manner. Inlined the determination of the options hash for reversing using a ternary operator. Shortens the method in a way that keeps the code neat
  Neatened up the invert_add_index method as per suggeston
  Simple fix for correctly inverting an add_index migration when a name has been provided
  Merge pull request #2524 from JonathonMA/fix_ecd37084b28a05f05251
  Fix Sprockets rewrite_asset_path
  Merge pull request #2620 from cesario/3-1-0
  Fix sprockets warnings
  Use typewriter styling on url_for in documentation
  Merge pull request #2609 from guilleiguaran/bump-sprockets-beta14
  remove extra space since comment_if already returns the space. (cherry picked from commit 5e73a2f)
  Merge pull request #2596 from dharmatech/patch-1
  Merge pull request #2595 from smartinez87/assets-guide
  Merge pull request #2597 from dharmatech/patch-2
  Merge pull request #2604 from vijaydev/params_wrapper_docs
  Merge pull request #2602 from ernie/fix_predicate_builder_primary_key_assumption
  Merge pull request #2603 from vijaydev/guides
  Merge pull request #2581 from guilleiguaran/debug-assets-in-dev
  Revert "Deprecate the use of non-public methods by Module#delegate"
  mailer guide: fixes indentation, and use fixed width fonts wherever necessary
  ...
1683ba2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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
@@ -141,6 +141,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)
@@ -151,11 +153,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
@@ -172,6 +180,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)
@@ -187,11 +197,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
Something went wrong with that request. Please try again.