diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-10-13 15:06:43 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-10-13 15:06:43 -0300 |
commit | 991d1bc200d6fdc379bc83610bc92a4e220c669e (patch) | |
tree | 84ace4c9c117ba7bc82824dbddf15485a9305bd2 /actionpack | |
parent | 0cf4662ec589813c4fdc22de3398730cab05c5ed (diff) | |
parent | 9cd50e7752650a3d6bf8545b51d50619d6e70c0b (diff) | |
download | rails-991d1bc200d6fdc379bc83610bc92a4e220c669e.tar.gz rails-991d1bc200d6fdc379bc83610bc92a4e220c669e.tar.bz2 rails-991d1bc200d6fdc379bc83610bc92a4e220c669e.zip |
Merge commit 'rails/master'
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/Gemfile | 2 | ||||
-rw-r--r-- | actionpack/lib/abstract_controller/callbacks.rb | 10 | ||||
-rw-r--r-- | actionpack/lib/action_controller/metal/session_management.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/http/mime_type.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/callbacks.rb | 8 | ||||
-rw-r--r-- | actionpack/lib/action_view/base.rb | 18 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/record_tag_helper.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_view/paths.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_view/render/partials.rb | 5 | ||||
-rw-r--r-- | actionpack/lib/action_view/render/rendering.rb | 22 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 28 | ||||
-rw-r--r-- | actionpack/test/lib/controller/fake_controllers.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/record_tag_helper_test.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/safe_buffer_test.rb (renamed from actionpack/test/view/safe_buffer_test.rb) | 2 |
14 files changed, 55 insertions, 66 deletions
diff --git a/actionpack/Gemfile b/actionpack/Gemfile index 60d24104d2..8ee7026f05 100644 --- a/actionpack/Gemfile +++ b/actionpack/Gemfile @@ -1,5 +1,7 @@ rails_root = Pathname.new(File.dirname(__FILE__)).join("..") +Gem.sources.each { |uri| source uri } + gem "rack", "~> 1.0.0" gem "rack-test", "~> 0.5.0" gem "activesupport", "3.0.pre", :vendored_at => rails_root.join("activesupport") diff --git a/actionpack/lib/abstract_controller/callbacks.rb b/actionpack/lib/abstract_controller/callbacks.rb index 379eaf6d8e..ee496dadc5 100644 --- a/actionpack/lib/abstract_controller/callbacks.rb +++ b/actionpack/lib/abstract_controller/callbacks.rb @@ -1,13 +1,11 @@ -require "active_support/new_callbacks" - module AbstractController module Callbacks extend ActiveSupport::Concern - # Uses ActiveSupport::NewCallbacks as the base functionality. For + # Uses ActiveSupport::Callbacks as the base functionality. For # more details on the whole callback system, read the documentation - # for ActiveSupport::NewCallbacks. - include ActiveSupport::NewCallbacks + # for ActiveSupport::Callbacks. + include ActiveSupport::Callbacks included do define_callbacks :process_action, :terminator => "response_body" @@ -16,7 +14,7 @@ module AbstractController # Override AbstractController::Base's process_action to run the # process_action callbacks around the normal behavior. def process_action(method_name) - _run_process_action_callbacks(method_name) do + run_callbacks(:process_action, method_name) do super end end diff --git a/actionpack/lib/action_controller/metal/session_management.rb b/actionpack/lib/action_controller/metal/session_management.rb index ffce8e1bd1..654aa08cd3 100644 --- a/actionpack/lib/action_controller/metal/session_management.rb +++ b/actionpack/lib/action_controller/metal/session_management.rb @@ -16,7 +16,7 @@ module ActionController #:nodoc: self.session_store = ActiveRecord::SessionStore else @@session_store = store.is_a?(Symbol) ? - Session.const_get(store.to_s.camelize) : + ActionDispatch::Session.const_get(store.to_s.camelize) : store end end diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index cc989d6625..e85823d8db 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -10,7 +10,12 @@ module Mime %w(<< concat shift unshift push pop []= clear compact! collect! delete delete_at delete_if flatten! map! insert reject! reverse! replace slice! sort! uniq!).each do |method| - define_method(method) {|*args| @symbols = nil; super(*args) } + module_eval <<-CODE + def #{method}(*args) + @symbols = nil + super + end + CODE end end diff --git a/actionpack/lib/action_dispatch/middleware/callbacks.rb b/actionpack/lib/action_dispatch/middleware/callbacks.rb index 56d6da1706..49bc20f11f 100644 --- a/actionpack/lib/action_dispatch/middleware/callbacks.rb +++ b/actionpack/lib/action_dispatch/middleware/callbacks.rb @@ -1,6 +1,6 @@ module ActionDispatch class Callbacks - include ActiveSupport::NewCallbacks + include ActiveSupport::Callbacks define_callbacks :call, :terminator => "result == false", :rescuable => true define_callbacks :prepare, :scope => :name @@ -37,12 +37,12 @@ module ActionDispatch def initialize(app, prepare_each_request = false) @app, @prepare_each_request = app, prepare_each_request - _run_prepare_callbacks + run_callbacks(:prepare) end def call(env) - _run_call_callbacks do - _run_prepare_callbacks if @prepare_each_request + run_callbacks(:call) do + run_callbacks(:prepare) if @prepare_each_request @app.call(env) end end diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 82b419d846..31e9c5ef9d 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -236,15 +236,15 @@ module ActionView #:nodoc: # they are in AC. if controller.class.respond_to?(:_helper_serial) klass = @views[controller.class._helper_serial] ||= Class.new(self) do - name = controller.class.name.gsub(/::/, '__') - - Subclasses.class_eval do - if method(:const_defined?).arity == 1 - remove_const(name) if const_defined?(name) # Ruby 1.8.x - else - remove_const(name) if const_defined?(name, false) # Ruby 1.9.x - end - const_set(name, self) + const_set(:CONTROLLER_CLASS, controller.class) + + # Try to make stack traces clearer + def self.name + "ActionView for #{CONTROLLER_CLASS}" + end + + def inspect + "#<#{self.class.name}>" end if controller.respond_to?(:_helpers) diff --git a/actionpack/lib/action_view/helpers/record_tag_helper.rb b/actionpack/lib/action_view/helpers/record_tag_helper.rb index 0cdb70e217..31411dc08a 100644 --- a/actionpack/lib/action_view/helpers/record_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/record_tag_helper.rb @@ -15,7 +15,7 @@ module ActionView def div_for(record, *args, &block) content_tag_for(:div, record, *args, &block) end - + # content_tag_for creates an HTML element with id and class parameters # that relate to the specified Active Record object. For example: # @@ -34,7 +34,7 @@ module ActionView # <% content_tag_for(:tr, @person, :foo) do %> ... # # produces: - # + # # <tr id="foo_person_123" class="person">... # # content_tag_for also accepts a hash of options, which will be converted to @@ -50,7 +50,7 @@ module ActionView def content_tag_for(tag_name, record, *args, &block) prefix = args.first.is_a?(Hash) ? nil : args.shift options = args.extract_options! - options.merge!({ :class => "#{dom_class(record)} #{options[:class]}".strip, :id => dom_id(record, prefix) }) + options.merge!({ :class => "#{dom_class(record, prefix)} #{options[:class]}".strip, :id => dom_id(record, prefix) }) content_tag(tag_name, options, &block) end end diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/paths.rb index 5524a3219a..23bde61f9c 100644 --- a/actionpack/lib/action_view/paths.rb +++ b/actionpack/lib/action_view/paths.rb @@ -1,8 +1,11 @@ module ActionView #:nodoc: class PathSet < Array #:nodoc: - def self.type_cast(obj) + def self.type_cast(obj, cache = nil) + # TODO: Clean this up if obj.is_a?(String) - cache = !defined?(Rails) || !Rails.respond_to?(:configuration) || Rails.configuration.cache_classes + if cache.nil? + cache = !defined?(Rails) || Rails.application.config.cache_classes + end FileSystemResolverWithFallback.new(obj, :cache => cache) else obj diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index 4f60566a09..2eb88ae3e5 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -296,7 +296,10 @@ module ActionView end def _find_template(path) - prefix = @view.controller.controller_path unless path.include?(?/) + if controller = @view.controller + prefix = controller.controller_path unless path.include?(?/) + end + @view.find(path, {:formats => @view.formats}, prefix, true) end diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb index 0cab035ede..b6f5b9b6d1 100644 --- a/actionpack/lib/action_view/render/rendering.rb +++ b/actionpack/lib/action_view/render/rendering.rb @@ -14,6 +14,7 @@ module ActionView case options when Hash layout = options[:layout] + options[:locals] ||= {} if block_given? return concat(_render_partial(options.merge(:partial => layout), &block)) @@ -25,11 +26,11 @@ module ActionView if file = options[:file] template = find(file, {:formats => formats}) - _render_template(template, layout, :locals => options[:locals] || {}) + _render_template(template, layout, :locals => options[:locals]) elsif inline = options[:inline] _render_inline(inline, layout, options) elsif text = options[:text] - _render_text(text, layout, options) + _render_text(text, layout, options[:locals]) end when :update update_page(&block) @@ -80,16 +81,19 @@ module ActionView def _render_inline(inline, layout, options) handler = Template.handler_class_for_extension(options[:type] || "erb") - template = Template.new(options[:inline], "inline #{options[:inline].inspect}", handler, {}) - locals = options[:locals] || {} + template = Template.new(options[:inline], + "inline #{options[:inline].inspect}", handler, {}) + + locals = options[:locals] content = template.render(self, locals) - content = layout.render(self, locals) {|*name| _layout_for(*name) { content } } if layout - content + _render_text(content, layout, locals) end - def _render_text(text, layout, options) - text = layout.render(self, options[:locals]) { text } if layout - text + def _render_text(content, layout, locals) + content = layout.render(self, locals) do |*name| + _layout_for(*name) { content } + end if layout + content end # This is the API to render a ViewContext's template from a controller. diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index edf243337f..7c88520bac 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -240,18 +240,6 @@ class LegacyRouteSetTests < Test::Unit::TestCase x.send(:home_url)) end - def test_basic_named_route_with_relative_url_root - rs.draw do |map| - map.home '', :controller => 'content', :action => 'list' - end - x = setup_for_named_route - ActionController::Base.relative_url_root = "/foo" - assert_equal("http://test.host/foo/", - x.send(:home_url)) - assert_equal "/foo/", x.send(:home_path) - ActionController::Base.relative_url_root = nil - end - def test_named_route_with_option rs.draw do |map| map.page 'page/:title', :controller => 'content', :action => 'show_page' @@ -307,19 +295,6 @@ class LegacyRouteSetTests < Test::Unit::TestCase x.send(:users_url)) end - def test_optimised_named_route_call_never_uses_url_for - rs.draw do |map| - map.users 'admin/user', :controller => '/admin/user', :action => 'index' - map.user 'admin/user/:id', :controller=>'/admin/user', :action=>'show' - end - x = setup_for_named_route - x.expects(:url_for).never - x.send(:users_url) - x.send(:users_path) - x.send(:user_url, 2, :foo=>"bar") - x.send(:user_path, 3, :bar=>"foo") - end - def test_optimised_named_route_with_host rs.draw do |map| map.pages 'pages', :controller => 'content', :action => 'show_page', :host => 'foo.com' @@ -984,9 +959,6 @@ class RouteSetTest < ActiveSupport::TestCase end assert_equal 1, set.routes.size - route = set.routes.first - - assert route.segments.last.optional? assert_equal '/users/show/10', set.generate(:controller => 'users', :action => 'show', :id => 10) assert_equal '/users/index/10', set.generate(:controller => 'users', :id => 10) diff --git a/actionpack/test/lib/controller/fake_controllers.rb b/actionpack/test/lib/controller/fake_controllers.rb index 9ec7f330b8..c993836a61 100644 --- a/actionpack/test/lib/controller/fake_controllers.rb +++ b/actionpack/test/lib/controller/fake_controllers.rb @@ -7,6 +7,7 @@ module Admin class << self; alias_method :const_available?, :const_defined?; end class UserController < ActionController::Base; end class NewsFeedController < ActionController::Base; end + class StuffController < ActionController::Base; end end module Api @@ -26,6 +27,7 @@ class HiController < ActionController::Base; end class ImageController < ActionController::Base; end class PeopleController < ActionController::Base; end class SessionsController < ActionController::Base; end +class StuffController < ActionController::Base; end class SubpathBooksController < ActionController::Base; end class WeblogController < ActionController::Base; end diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb index 77d1374020..1cd18c0692 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -27,7 +27,7 @@ class RecordTagHelperTest < ActionView::TestCase end def test_content_tag_for_prefix - expected = %(<ul class="post" id="archived_post_45"></ul>) + expected = %(<ul class="archived_post" id="archived_post_45"></ul>) actual = content_tag_for(:ul, @post, :archived) { } assert_dom_equal expected, actual end diff --git a/actionpack/test/view/safe_buffer_test.rb b/actionpack/test/template/safe_buffer_test.rb index 2236709627..6a18201d16 100644 --- a/actionpack/test/view/safe_buffer_test.rb +++ b/actionpack/test/template/safe_buffer_test.rb @@ -26,7 +26,7 @@ class SafeBufferTest < ActionView::TestCase end test "Should not mess with a previously escape test" do - @buffer << CGI.escapeHTML("<script>") + @buffer << ERB::Util.html_escape("<script>") assert_equal "<script>", @buffer end |