diff options
Diffstat (limited to 'actionpack')
12 files changed, 83 insertions, 44 deletions
diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec index 6beaec7158..d7c8aeadd3 100644 --- a/actionpack/actionpack.gemspec +++ b/actionpack/actionpack.gemspec @@ -20,10 +20,11 @@ Gem::Specification.new do |s| s.add_dependency('activemodel', version) s.add_dependency('rack-cache', '~> 1.0.1') s.add_dependency('builder', '~> 3.0.0') - s.add_dependency('rack', '~> 1.3.0.beta2') + s.add_dependency('i18n', '~> 0.6') + s.add_dependency('rack', '~> 1.3.0') s.add_dependency('rack-test', '~> 0.6.0') s.add_dependency('rack-mount', '~> 0.8.1') - s.add_dependency('sprockets', '~> 2.0.0.beta.5') + s.add_dependency('sprockets', '~> 2.0.0.beta.8') s.add_dependency('tzinfo', '~> 0.3.27') s.add_dependency('erubis', '~> 2.7.0') end diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb index eba5e9377b..f13fd71050 100644 --- a/actionpack/lib/action_controller.rb +++ b/actionpack/lib/action_controller.rb @@ -37,12 +37,13 @@ module ActionController autoload :UrlFor end - autoload :Integration, 'action_controller/deprecated/integration_test' - autoload :IntegrationTest, 'action_controller/deprecated/integration_test' - autoload :PerformanceTest, 'action_controller/deprecated/performance_test' - autoload :UrlWriter, 'action_controller/deprecated' - autoload :Routing, 'action_controller/deprecated' - autoload :TestCase, 'action_controller/test_case' + autoload :Integration, 'action_controller/deprecated/integration_test' + autoload :IntegrationTest, 'action_controller/deprecated/integration_test' + autoload :PerformanceTest, 'action_controller/deprecated/performance_test' + autoload :UrlWriter, 'action_controller/deprecated' + autoload :Routing, 'action_controller/deprecated' + autoload :TestCase, 'action_controller/test_case' + autoload :TemplateAssertions, 'action_controller/test_case' eager_autoload do autoload :RecordIdentifier diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index 3a6b1da4fd..76d0857b93 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -33,7 +33,8 @@ module ActionDispatch # :nodoc: # end # end class Response - attr_accessor :request, :header, :status + attr_accessor :request, :header + attr_reader :status attr_writer :sending_file alias_method :headers=, :header= diff --git a/actionpack/lib/action_dispatch/testing/assertions.rb b/actionpack/lib/action_dispatch/testing/assertions.rb index 822150b768..226baf9ad0 100644 --- a/actionpack/lib/action_dispatch/testing/assertions.rb +++ b/actionpack/lib/action_dispatch/testing/assertions.rb @@ -8,12 +8,11 @@ module ActionDispatch extend ActiveSupport::Concern - included do - include DomAssertions - include ResponseAssertions - include RoutingAssertions - include SelectorAssertions - include TagAssertions - end + include DomAssertions + include ResponseAssertions + include RoutingAssertions + include SelectorAssertions + include TagAssertions end end + diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb index 3335742d47..606b01893e 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/response.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb @@ -6,13 +6,6 @@ module ActionDispatch module ResponseAssertions extend ActiveSupport::Concern - included do - # TODO: Need to pull in AV::Template monkey patches that track which - # templates are rendered. assert_template should probably be part - # of AV instead of AD. - require 'action_view/test_case' - end - # Asserts that the response is one of the following types: # # * <tt>:success</tt> - Status code was 200 diff --git a/actionpack/lib/action_view/helpers/sprockets_helper.rb b/actionpack/lib/action_view/helpers/sprockets_helper.rb index ab98da9624..e5d780225b 100644 --- a/actionpack/lib/action_view/helpers/sprockets_helper.rb +++ b/actionpack/lib/action_view/helpers/sprockets_helper.rb @@ -4,28 +4,53 @@ require 'action_view/helpers/asset_paths' module ActionView module Helpers module SprocketsHelper - def asset_path(source, default_ext = nil) - sprockets_asset_paths.compute_public_path(source, 'assets', default_ext, true) + def debug_assets? + params[:debug_assets] == '1' || + params[:debug_assets] == 'true' + end + + def asset_path(source, default_ext = nil, body = false) + source = source.logical_path if source.respond_to?(:logical_path) + path = sprockets_asset_paths.compute_public_path(source, 'assets', default_ext, true) + body ? "#{path}?body=1" : path end def sprockets_javascript_include_tag(source, options = {}) - options = { - 'type' => "text/javascript", - 'src' => asset_path(source, 'js') - }.merge(options.stringify_keys) + debug = options.key?(:debug) ? options.delete(:debug) : debug_assets? + body = options.key?(:body) ? options.delete(:body) : false - content_tag 'script', "", options + if debug && asset = sprockets_asset_paths.asset_for(source, 'js') + asset.to_a.map { |dep| + sprockets_javascript_include_tag(dep, :debug => false, :body => true) + }.join("\n").html_safe + else + options = { + 'type' => "text/javascript", + 'src' => asset_path(source, 'js', body) + }.merge(options.stringify_keys) + + content_tag 'script', "", options + end end def sprockets_stylesheet_link_tag(source, options = {}) - options = { - 'rel' => "stylesheet", - 'type' => "text/css", - 'media' => "screen", - 'href' => asset_path(source, 'css') - }.merge(options.stringify_keys) + debug = options.key?(:debug) ? options.delete(:debug) : debug_assets? + body = options.key?(:body) ? options.delete(:body) : false - tag 'link', options + if debug && asset = sprockets_asset_paths.asset_for(source, 'css') + asset.to_a.map { |dep| + sprockets_stylesheet_link_tag(dep, :debug => false, :body => true) + }.join("\n").html_safe + else + options = { + 'rel' => "stylesheet", + 'type' => "text/css", + 'media' => "screen", + 'href' => asset_path(source, 'css', body) + }.merge(options.stringify_keys) + + tag 'link', options + end end private @@ -39,6 +64,13 @@ module ActionView end class AssetPaths < ActionView::Helpers::AssetPaths #:nodoc: + def asset_for(source, ext) + source = source.to_s + return nil if is_uri?(source) + source = rewrite_extension(source, nil, ext) + assets[source] + end + def rewrite_asset_path(source, dir) if source[0] == ?/ source @@ -66,4 +98,4 @@ module ActionView end end end -end
\ No newline at end of file +end diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index fada0c7748..82c2c23607 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -187,6 +187,9 @@ class ActionCachingTestController < CachingController rescue_from(ActiveRecord::RecordNotFound) { head :not_found } end + # Eliminate uninitialized ivar warning + before_filter { @title = nil } + caches_action :index, :redirected, :forbidden, :if => Proc.new { |c| !c.request.format.json? }, :expires_in => 1.hour caches_action :show, :cache_path => 'http://test.host/custom/show' caches_action :edit, :cache_path => Proc.new { |c| c.params[:id] ? "http://test.host/#{c.params[:id]};edit" : "http://test.host/edit" } diff --git a/actionpack/test/fixtures/sprockets/app/javascripts/application.js b/actionpack/test/fixtures/sprockets/app/javascripts/application.js index e69de29bb2..e611d2b129 100644 --- a/actionpack/test/fixtures/sprockets/app/javascripts/application.js +++ b/actionpack/test/fixtures/sprockets/app/javascripts/application.js @@ -0,0 +1 @@ +//= require xmlhr diff --git a/actionpack/test/fixtures/sprockets/app/stylesheets/application.css b/actionpack/test/fixtures/sprockets/app/stylesheets/application.css index e69de29bb2..2365eaa4cd 100644 --- a/actionpack/test/fixtures/sprockets/app/stylesheets/application.css +++ b/actionpack/test/fixtures/sprockets/app/stylesheets/application.css @@ -0,0 +1 @@ +/*= require style */ diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index 8d3be09a4f..9d1e08373f 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -2,8 +2,6 @@ require 'abstract_unit' require 'sprockets' require 'mocha' -module Rails; end - class SprocketsHelperTest < ActionView::TestCase tests ActionView::Helpers::SprocketsHelper @@ -13,6 +11,7 @@ class SprocketsHelperTest < ActionView::TestCase super @controller = BasicController.new + @controller.stubs(:params).returns({}) @request = Class.new do def protocol() 'http://' end @@ -85,10 +84,13 @@ class SprocketsHelperTest < ActionView::TestCase sprockets_javascript_include_tag("xmlhr.js") assert_equal '<script src="http://www.example.com/xmlhr" type="text/javascript"></script>', sprockets_javascript_include_tag("http://www.example.com/xmlhr") + + assert_equal "<script src=\"/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js?body=1\" type=\"text/javascript\"></script>\n<script src=\"/assets/application-d41d8cd98f00b204e9800998ecf8427e.js?body=1\" type=\"text/javascript\"></script>", + sprockets_javascript_include_tag(:application, :debug => true) end test "stylesheet path" do - assert_equal "/assets/application-d41d8cd98f00b204e9800998ecf8427e.css", asset_path(:application, "css") + assert_equal "/assets/application-68b329da9893e34099c7d8ad5cb9c940.css", asset_path(:application, "css") assert_equal "/assets/style-d41d8cd98f00b204e9800998ecf8427e.css", asset_path("style", "css") assert_equal "/assets/dir/style-d41d8cd98f00b204e9800998ecf8427e.css", asset_path("dir/style.css", "css") @@ -101,7 +103,7 @@ class SprocketsHelperTest < ActionView::TestCase end test "stylesheet link tag" do - assert_equal '<link href="/assets/application-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />', + assert_equal '<link href="/assets/application-68b329da9893e34099c7d8ad5cb9c940.css" media="screen" rel="stylesheet" type="text/css" />', sprockets_stylesheet_link_tag(:application) assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />', @@ -115,5 +117,8 @@ class SprocketsHelperTest < ActionView::TestCase sprockets_stylesheet_link_tag("style", :media => "all") assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="print" rel="stylesheet" type="text/css" />', sprockets_stylesheet_link_tag("style", :media => "print") + + assert_equal "<link href=\"/assets/style-d41d8cd98f00b204e9800998ecf8427e.css?body=1\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<link href=\"/assets/application-68b329da9893e34099c7d8ad5cb9c940.css?body=1\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />", + sprockets_stylesheet_link_tag(:application, :debug => true) end end diff --git a/actionpack/test/template/streaming_render_test.rb b/actionpack/test/template/streaming_render_test.rb index b2df8efee3..023ce723ed 100644 --- a/actionpack/test/template/streaming_render_test.rb +++ b/actionpack/test/template/streaming_render_test.rb @@ -8,7 +8,7 @@ end class FiberedTest < ActiveSupport::TestCase def setup view_paths = ActionController::Base.view_paths - @assigns = { :secret => 'in the sauce' } + @assigns = { :secret => 'in the sauce', :name => nil } @view = ActionView::Base.new(view_paths, @assigns) @controller_view = TestController.new.view_context end @@ -106,4 +106,4 @@ class FiberedTest < ActiveSupport::TestCase buffered_render(:template => "test/nested_streaming", :layout => "layouts/streaming") end -end if defined?(Fiber)
\ No newline at end of file +end if defined?(Fiber) diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 8d0f0124c2..4aa45c8bf0 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -25,6 +25,8 @@ class UrlHelperTest < ActiveSupport::TestCase include ActionView::Context include RenderERBUtils + setup :_prepare_context + def hash_for(opts = []) ActiveSupport::OrderedHash[*([:controller, "foo", :action, "bar"].concat(opts))] end |