From 7223f10acda3d5683e6de817bc7131ca109f3f28 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Thu, 18 Aug 2011 14:59:27 -0500 Subject: Debug assets by default in development and test environments --- actionpack/lib/sprockets/helpers/rails_helper.rb | 4 ++-- actionpack/test/template/sprockets_helper_test.rb | 28 ++++++++++++++++++----- 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{}, 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("xmlhr", "extra") + + Rails.env.stubs(:test?).returns(true) + assert_match %r{\n}, - javascript_include_tag(:application, :debug => true) + javascript_include_tag(:application) + + assert_match %r{}, + javascript_include_tag(:application, :debug => false) - assert_match %r{\n}, - 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{}, 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 -- cgit v1.2.3