diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG.md | 5 | ||||
-rw-r--r-- | actionpack/actionpack.gemspec | 2 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/testing/integration.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb | 15 | ||||
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 9 |
5 files changed, 26 insertions, 12 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index cc1c6ba46b..9d413c8fb3 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,8 @@ +## Rails 3.2.9 (unreleased) ## + +* `javascript_include_tag :all` will now not include `application.js` if the file does not exists. *Prem Sichanugrist* + + ## Rails 3.2.8 (Aug 9, 2012) ## * There is an XSS vulnerability in the strip_tags helper in Ruby on Rails, the diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec index ac2040935f..3d67541557 100644 --- a/actionpack/actionpack.gemspec +++ b/actionpack/actionpack.gemspec @@ -23,7 +23,7 @@ Gem::Specification.new do |s| s.add_dependency('rack', '~> 1.4.0') s.add_dependency('rack-test', '~> 0.6.1') s.add_dependency('journey', '~> 1.0.4') - s.add_dependency('sprockets', '~> 2.1.3') + s.add_dependency('sprockets', '~> 2.1') s.add_dependency('erubis', '~> 2.7.0') s.add_development_dependency('tzinfo', '~> 0.3.29') diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index ac784b3b60..a4c6c84939 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -18,8 +18,8 @@ module ActionDispatch # a Hash, or a String that is appropriately encoded # (<tt>application/x-www-form-urlencoded</tt> or # <tt>multipart/form-data</tt>). - # - +headers+: Additional HTTP headers to pass, as a Hash. The keys will - # automatically be upcased, with the prefix 'HTTP_' added if needed. + # - +headers+: Additional headers to pass, as a Hash. The headers will be + # merged into the Rack env hash. # # This method returns an Response object, which one can use to # inspect the details of the response. Furthermore, if this method was @@ -62,8 +62,7 @@ module ActionDispatch # # The request_method is +:get+, +:post+, +:put+, +:delete+ or +:head+; the # parameters are +nil+, a hash, or a url-encoded or multipart string; - # the headers are a hash. Keys are automatically upcased and prefixed - # with 'HTTP_' if not already. + # the headers are a hash. def xml_http_request(request_method, path, parameters = nil, headers = nil) headers ||= {} headers['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest' diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb index d9f1f88ade..b79b625c12 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb @@ -27,7 +27,8 @@ module ActionView def expand_sources(sources, recursive = false) if sources.include?(:all) - all_asset_files = (collect_asset_files(custom_dir, ('**' if recursive), "*.#{extension}") - ['application']) << 'application' + all_asset_files = (collect_asset_files(custom_dir, ('**' if recursive), "*.#{extension}") - ['application']) + add_application_js(all_asset_files, sources) ((determine_source(:defaults, expansions).dup & all_asset_files) + all_asset_files).uniq else expanded_sources = sources.inject([]) do |list, source| @@ -40,7 +41,7 @@ module ActionView end def add_application_js(expanded_sources, sources) - if sources.include?(:defaults) && File.exist?(File.join(custom_dir, "application.#{extension}")) + if (sources.include?(:defaults) || sources.include?(:all)) && File.exist?(File.join(custom_dir, "application.#{extension}")) expanded_sources.delete('application') expanded_sources << "application" end @@ -101,8 +102,8 @@ module ActionView # # config.action_view.javascript_expansions[:defaults] = %w(foo.js bar.js) # - # When using <tt>:defaults</tt>, if an <tt>application.js</tt> file exists in - # <tt>public/javascripts</tt> it will be included as well at the end. + # When using <tt>:defaults</tt> or <tt>:all</tt>, if an <tt>application.js</tt> file exists + # in <tt>public/javascripts</tt> it will be included as well at the end. # # You can modify the HTML attributes of the script tag by passing a hash as the # last argument. @@ -129,16 +130,16 @@ module ActionView # # <script type="text/javascript" src="/javascripts/rails.js?1284139606"></script> # # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script> # - # * = The application.js file is only referenced if it exists + # Note: The application.js file is only referenced if it exists # # You can also include all JavaScripts in the +javascripts+ directory using <tt>:all</tt> as the source: # # javascript_include_tag :all # # => <script type="text/javascript" src="/javascripts/jquery.js?1284139606"></script> # # <script type="text/javascript" src="/javascripts/rails.js?1284139606"></script> - # # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script> # # <script type="text/javascript" src="/javascripts/shop.js?1284139606"></script> # # <script type="text/javascript" src="/javascripts/checkout.js?1284139606"></script> + # # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script> # # Note that your defaults of choice will be included first, so they will be available to all subsequently # included files. @@ -161,9 +162,9 @@ module ActionView # javascript_include_tag :all, :cache => true # # => <script type="text/javascript" src="/javascripts/jquery.js?1284139606"></script> # # <script type="text/javascript" src="/javascripts/rails.js?1284139606"></script> - # # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script> # # <script type="text/javascript" src="/javascripts/shop.js?1284139606"></script> # # <script type="text/javascript" src="/javascripts/checkout.js?1284139606"></script> + # # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script> # # # assuming config.perform_caching is true # javascript_include_tag :all, :cache => true diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 6a0fdf0590..b1a01b53b1 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -338,6 +338,15 @@ class AssetTagHelperTest < ActionView::TestCase assert_raise(ArgumentError) { javascript_include_tag(:defaults) } end + def test_all_javascript_expansion_not_include_application_js_if_not_exists + FileUtils.mv(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'application.js'), + File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'application.bak')) + assert_no_match(/application\.js/, javascript_include_tag(:all)) + ensure + FileUtils.mv(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'application.bak'), + File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'application.js')) + end + def test_stylesheet_path ENV["RAILS_ASSET_ID"] = "" StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } |