<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>vendor/rails/REVISION_a70c78177a564c2f2cd09846a5e7ab6e8669e9f2</filename>
    </added>
    <added>
      <filename>vendor/rails/actionpack/lib/action_controller/caching/sweeper.rb</filename>
    </added>
    <added>
      <filename>vendor/rails/actionpack/test/controller/request/test_request_test.rb</filename>
    </added>
    <added>
      <filename>vendor/rails/actionpack/test/template/template_test.rb</filename>
    </added>
    <added>
      <filename>vendor/rails/activerecord/test/cases/timestamp_test.rb</filename>
    </added>
    <added>
      <filename>vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb</filename>
    </added>
    <added>
      <filename>vendor/rails/activesupport/lib/active_support/json/backends/yaml.rb</filename>
    </added>
    <added>
      <filename>vendor/rails/activesupport/lib/active_support/xml_mini/jdom.rb</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/files/javascripts/code_highlighter.js</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/files/javascripts/guides.js</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/files/javascripts/highlighters.js</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/files/stylesheets/main.css</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/files/stylesheets/print.css</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/files/stylesheets/reset.css</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/files/stylesheets/style.css</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/files/stylesheets/syntax.css</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/belongs_to.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/book_icon.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/bullet.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/chapters_icon.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/check_bullet.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/credits_pic_blank.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/csrf.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/customized_error_messages.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/error_messages.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/feature_tile.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/footer_tile.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/fxn.jpg</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/grey_bullet.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/habtm.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/has_many.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/has_many_through.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/has_one.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/has_one_through.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/header_backdrop.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/header_tile.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/i18n/demo_localized_pirate.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/i18n/demo_translated_en.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/i18n/demo_translated_pirate.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/i18n/demo_translation_missing.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/i18n/demo_untranslated.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/README</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/1.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/10.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/11.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/12.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/13.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/14.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/15.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/2.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/3.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/4.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/5.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/6.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/7.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/8.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/callouts/9.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/caution.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/example.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/home.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/important.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/next.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/note.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/prev.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/tip.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/up.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/icons/warning.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/nav_arrow.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/polymorphic.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/posts_index.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/rails_guides_logo.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/rails_logo_remix.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/rails_welcome.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/session_fixation.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/tab_grey.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/tab_info.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/tab_note.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/tab_red.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/tab_yellow.gif</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/tab_yellow.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/images/validation_error_messages.png</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/rails_guides.rb</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/rails_guides/generator.rb</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/rails_guides/helpers.rb</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/rails_guides/indexer.rb</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/rails_guides/textile_extensions.rb</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/2_2_release_notes.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/2_3_release_notes.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/action_controller_overview.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/action_mailer_basics.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/active_record_basics.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/active_record_querying.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/activerecord_validations_callbacks.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/association_basics.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/caching_with_rails.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/command_line.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/configuring.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/contribute.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/contributing_to_rails.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/credits.erb.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/debugging_rails_applications.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/form_helpers.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/getting_started.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/i18n.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/index.erb.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/layout.html.erb</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/layouts_and_rendering.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/migrations.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/nested_model_forms.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/performance_testing.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/plugins.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/rails_on_rack.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/routing.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/security.textile</filename>
    </added>
    <added>
      <filename>vendor/rails/railties/guides/source/testing.textile</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,8 @@
+*2.3.3 (pending)*
+
+* Fixed that TestResponse.cookies was returning cookies unescaped #1867 [Doug McInnes]
+
+
 *2.3.2 [Final] (March 15, 2009)*
 
 * Fixed that redirection would just log the options, not the final url (which lead to &quot;Redirected to #&lt;Post:0x23150b8&gt;&quot;) [DHH]</diff>
      <filename>vendor/rails/actionpack/CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -31,12 +31,8 @@ rescue LoadError
   end
 end
 
-begin
-  gem 'rack', '~&gt; 1.0.0'
-  require 'rack'
-rescue Gem::LoadError
-  require 'action_controller/vendor/rack-1.0/rack'
-end
+gem 'rack', '~&gt; 1.0.0'
+require 'rack'
 
 module ActionController
   # TODO: Review explicit to see if they will automatically be handled by</diff>
      <filename>vendor/rails/actionpack/lib/action_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -63,7 +63,10 @@ module ActionController
 
           # Support partial arguments for hash redirections
           if options.is_a?(Hash) &amp;&amp; @response.redirected_to.is_a?(Hash)
-            return true if options.all? {|(key, value)| @response.redirected_to[key] == value}
+            if options.all? {|(key, value)| @response.redirected_to[key] == value}
+              ::ActiveSupport::Deprecation.warn(&quot;Using assert_redirected_to with partial hash arguments is deprecated. Specify the full set arguments instead&quot;, caller)
+              return true
+            end
           end
 
           redirected_to_after_normalisation = normalize_argument_to_redirection(@response.redirected_to)
@@ -82,6 +85,9 @@ module ActionController
       #   # assert that the &quot;new&quot; view template was rendered
       #   assert_template &quot;new&quot;
       #
+      #   # assert that the &quot;new&quot; view template was rendered with Symbol
+      #   assert_template :new
+      #
       #   # assert that the &quot;_customer&quot; partial was rendered twice
       #   assert_template :partial =&gt; '_customer', :count =&gt; 2
       #
@@ -91,7 +97,7 @@ module ActionController
       def assert_template(options = {}, message = nil)
         clean_backtrace do
           case options
-           when NilClass, String
+           when NilClass, String, Symbol
             rendered = @response.rendered[:template].to_s
             msg = build_message(message,
                     &quot;expecting &lt;?&gt; but rendering with &lt;?&gt;&quot;,
@@ -100,7 +106,7 @@ module ActionController
               if options.nil?
                 @response.rendered[:template].blank?
               else
-                rendered.to_s.match(options)
+                rendered.to_s.match(options.to_s)
               end
             end
           when Hash
@@ -123,6 +129,8 @@ module ActionController
               assert @response.rendered[:partials].empty?,
                 &quot;Expected no partials to be rendered&quot;
             end
+          else
+            raise ArgumentError  
           end
         end
       end</diff>
      <filename>vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -950,8 +950,9 @@ module ActionController #:nodoc:
             response.content_type ||= Mime::JS
             render_for_text(js, options[:status])
 
-          elsif json = options[:json]
-            json = json.to_json unless json.is_a?(String)
+          elsif options.include?(:json)
+            json = options[:json]
+            json = ActiveSupport::JSON.encode(json) unless json.is_a?(String)
             json = &quot;#{options[:callback]}(#{json})&quot; unless options[:callback].blank?
             response.content_type ||= Mime::JSON
             render_for_text(json, options[:status])</diff>
      <filename>vendor/rails/actionpack/lib/action_controller/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -27,7 +27,7 @@ module ActionController #:nodoc:
     autoload :Actions, 'action_controller/caching/actions'
     autoload :Fragments, 'action_controller/caching/fragments'
     autoload :Pages, 'action_controller/caching/pages'
-    autoload :Sweeper, 'action_controller/caching/sweeping'
+    autoload :Sweeper, 'action_controller/caching/sweeper'
     autoload :Sweeping, 'action_controller/caching/sweeping'
 
     def self.included(base) #:nodoc:</diff>
      <filename>vendor/rails/actionpack/lib/action_controller/caching.rb</filename>
    </modified>
    <modified>
      <diff>@@ -61,7 +61,9 @@ module ActionController #:nodoc:
           filter_options = { :only =&gt; actions, :if =&gt; options.delete(:if), :unless =&gt; options.delete(:unless) }
 
           cache_filter = ActionCacheFilter.new(:layout =&gt; options.delete(:layout), :cache_path =&gt; options.delete(:cache_path), :store_options =&gt; options)
-          around_filter(cache_filter, filter_options)
+          around_filter(filter_options) do |controller, action|
+            cache_filter.filter(controller, action)
+          end
         end
       end
 
@@ -83,6 +85,12 @@ module ActionController #:nodoc:
           @options = options
         end
 
+        def filter(controller, action)
+          should_continue = before(controller)
+          action.call if should_continue
+          after(controller)
+        end
+
         def before(controller)
           cache_path = ActionCachePath.new(controller, path_options_for(controller, @options.slice(:cache_path)))
           if cache = controller.read_fragment(cache_path.path, @options[:store_options])</diff>
      <filename>vendor/rails/actionpack/lib/action_controller/caching/actions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -51,47 +51,5 @@ module ActionController #:nodoc:
         end
       end
     end
-
-    if defined?(ActiveRecord) and defined?(ActiveRecord::Observer)
-      class Sweeper &lt; ActiveRecord::Observer #:nodoc:
-        attr_accessor :controller
-
-        def before(controller)
-          self.controller = controller
-          callback(:before) if controller.perform_caching
-        end
-
-        def after(controller)
-          callback(:after) if controller.perform_caching
-          # Clean up, so that the controller can be collected after this request
-          self.controller = nil
-        end
-
-        protected
-          # gets the action cache path for the given options.
-          def action_path_for(options)
-            ActionController::Caching::Actions::ActionCachePath.path_for(controller, options)
-          end
-
-          # Retrieve instance variables set in the controller.
-          def assigns(key)
-            controller.instance_variable_get(&quot;@#{key}&quot;)
-          end
-
-        private
-          def callback(timing)
-            controller_callback_method_name = &quot;#{timing}_#{controller.controller_name.underscore}&quot;
-            action_callback_method_name     = &quot;#{controller_callback_method_name}_#{controller.action_name}&quot;
-
-            __send__(controller_callback_method_name) if respond_to?(controller_callback_method_name, true)
-            __send__(action_callback_method_name)     if respond_to?(action_callback_method_name, true)
-          end
-
-          def method_missing(method, *arguments, &amp;block)
-            return if @controller.nil?
-            @controller.__send__(method, *arguments, &amp;block)
-          end
-      end
-    end
   end
 end</diff>
      <filename>vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@ module ActionController
       @app.call(env)
     rescue Exception =&gt; exception
       # Reraise exception in test environment
-      if env[&quot;rack.test&quot;]
+      if defined?(Rails) &amp;&amp; Rails.env.test?
         raise exception
       else
         failsafe_response(exception)</diff>
      <filename>vendor/rails/actionpack/lib/action_controller/failsafe.rb</filename>
    </modified>
    <modified>
      <diff>@@ -192,9 +192,10 @@ module ActionController
 
         if valid_nonce &amp;&amp; realm == credentials[:realm] &amp;&amp; opaque == credentials[:opaque]
           password = password_procedure.call(credentials[:username])
+          method = request.env['rack.methodoverride.original_method'] || request.env['REQUEST_METHOD']
 
          [true, false].any? do |password_is_ha1|
-           expected = expected_response(request.env['REQUEST_METHOD'], request.env['REQUEST_URI'], credentials, password, password_is_ha1)
+           expected = expected_response(method, request.env['REQUEST_URI'], credentials, password, password_is_ha1)
            expected == credentials[:response]
          end
         end</diff>
      <filename>vendor/rails/actionpack/lib/action_controller/http_authentication.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ require 'active_support/test_case'
 module ActionController
   module Integration #:nodoc:
     # An integration Session instance represents a set of requests and responses
-    # performed sequentially by some virtual user. Becase you can instantiate
+    # performed sequentially by some virtual user. Because you can instantiate
     # multiple sessions and run them side-by-side, you can also mimic (to some
     # limited extent) multiple simultaneous users interacting with your system.
     #
@@ -292,9 +292,7 @@ module ActionController
             &quot;rack.errors&quot;       =&gt; StringIO.new,
             &quot;rack.multithread&quot;  =&gt; true,
             &quot;rack.multiprocess&quot; =&gt; true,
-            &quot;rack.run_once&quot;     =&gt; false,
-
-            &quot;rack.test&quot; =&gt; true
+            &quot;rack.run_once&quot;     =&gt; false
           )
 
           (headers || {}).each do |key, value|</diff>
      <filename>vendor/rails/actionpack/lib/action_controller/integration.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,6 @@ use &quot;ActionController::Failsafe&quot;
 use lambda { ActionController::Base.session_store },
     lambda { ActionController::Base.session_options }
 
-use &quot;ActionController::RewindableInput&quot;
 use &quot;ActionController::ParamsParser&quot;
 use &quot;Rack::MethodOverride&quot;
 use &quot;Rack::Head&quot;</diff>
      <filename>vendor/rails/actionpack/lib/action_controller/middlewares.rb</filename>
    </modified>
    <modified>
      <diff>@@ -95,6 +95,10 @@ module ActionController
       end
     end
 
+    def media_type
+      content_type.to_s
+    end
+
     # Returns the accepted MIME type for the request.
     def accepts
       @accepts ||= begin
@@ -383,7 +387,7 @@ EOM
     alias_method :params, :parameters
 
     def path_parameters=(parameters) #:nodoc:
-      @env[&quot;rack.routing_args&quot;] = parameters
+      @env[&quot;action_controller.request.path_parameters&quot;] = parameters
       @symbolized_path_parameters = @parameters = nil
     end
 
@@ -399,7 +403,7 @@ EOM
     #
     # See &lt;tt&gt;symbolized_path_parameters&lt;/tt&gt; for symbolized keys.
     def path_parameters
-      @env[&quot;rack.routing_args&quot;] ||= {}
+      @env[&quot;action_controller.request.path_parameters&quot;] ||= {}
     end
 
     # The request body is an IO input stream. If the RAW_POST_DATA environment</diff>
      <filename>vendor/rails/actionpack/lib/action_controller/request.rb</filename>
    </modified>
    <modified>
      <diff>@@ -152,7 +152,7 @@ module ActionController # :nodoc:
         @writer = lambda { |x| callback.call(x) }
         @body.call(self, self)
       elsif @body.is_a?(String)
-        @body.each_line(&amp;callback)
+        yield @body
       else
         @body.each(&amp;callback)
       end</diff>
      <filename>vendor/rails/actionpack/lib/action_controller/response.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,4 @@
+require 'rack/session/abstract/id'
 module ActionController #:nodoc:
   class TestRequest &lt; Request #:nodoc:
     attr_accessor :cookies, :session_options
@@ -13,6 +14,8 @@ module ActionController #:nodoc:
 
       @query_parameters   = {}
       @session            = TestSession.new
+      default_rack_options = Rack::Session::Abstract::ID::DEFAULT_OPTIONS
+      @session_options    ||= {:id =&gt; generate_sid(default_rack_options[:sidbits])}.merge(default_rack_options)
 
       initialize_default_values
       initialize_containers
@@ -110,6 +113,7 @@ module ActionController #:nodoc:
     end
 
     def recycle!
+      @env[&quot;action_controller.request.request_parameters&quot;] = {}
       self.query_parameters   = {}
       self.path_parameters    = {}
       @headers, @request_method, @accepts, @content_type = nil, nil, nil, nil
@@ -120,6 +124,10 @@ module ActionController #:nodoc:
     end
 
     private
+      def generate_sid(sidbits)
+        &quot;%0#{sidbits / 4}x&quot; % rand(2**sidbits - 1)
+      end
+
       def initialize_containers
         @cookies = {}
       end
@@ -250,7 +258,7 @@ module ActionController #:nodoc:
     def cookies
       cookies = {}
       Array(headers['Set-Cookie']).each do |cookie|
-        key, value = cookie.split(&quot;;&quot;).first.split(&quot;=&quot;)
+        key, value = cookie.split(&quot;;&quot;).first.split(&quot;=&quot;).map {|val| Rack::Utils.unescape(val)}
         cookies[key] = value
       end
       cookies</diff>
      <filename>vendor/rails/actionpack/lib/action_controller/test_process.rb</filename>
    </modified>
    <modified>
      <diff>@@ -876,8 +876,8 @@ module ActionView
           input_name_from_type(type).gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '')
         end
 
-        # Given an ordering of datetime components, create the selection html
-        # and join them with their appropriate seperators
+        # Given an ordering of datetime components, create the selection HTML
+        # and join them with their appropriate separators.
         def build_selects_from_types(order)
           select = ''
           order.reverse.each do |type|</diff>
      <filename>vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -230,6 +230,8 @@ module ActionView
       #
       # NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.
       def options_for_select(container, selected = nil)
+        return container if String === container
+
         container = container.to_a if Hash === container
         selected, disabled = extract_selected_and_disabled(selected)
 </diff>
      <filename>vendor/rails/actionpack/lib/action_view/helpers/form_options_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -140,7 +140,7 @@ module ActionView
       #  number_with_delimiter(12345678)                        # =&gt; 12,345,678
       #  number_with_delimiter(12345678.05)                     # =&gt; 12,345,678.05
       #  number_with_delimiter(12345678, :delimiter =&gt; &quot;.&quot;)     # =&gt; 12.345.678
-      #  number_with_delimiter(12345678, :seperator =&gt; &quot;,&quot;)     # =&gt; 12,345,678
+      #  number_with_delimiter(12345678, :separator =&gt; &quot;,&quot;)     # =&gt; 12,345,678
       #  number_with_delimiter(98765432.98, :delimiter =&gt; &quot; &quot;, :separator =&gt; &quot;,&quot;)
       #  # =&gt; 98 765 432,98
       #</diff>
      <filename>vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -973,7 +973,7 @@ module ActionView
             def loop_on_multiple_args(method, ids)
               record(ids.size&gt;1 ?
                 &quot;#{javascript_object_for(ids)}.each(#{method})&quot; :
-                &quot;#{method}(#{ids.first.to_json})&quot;)
+                &quot;#{method}(#{ActiveSupport::JSON.encode(ids.first)})&quot;)
             end
 
             def page
@@ -997,7 +997,7 @@ module ActionView
             end
 
             def javascript_object_for(object)
-              object.respond_to?(:to_json) ? object.to_json : object.inspect
+              ActiveSupport::JSON.encode(object)
             end
 
             def arguments_for_call(arguments, block = nil)
@@ -1139,7 +1139,7 @@ module ActionView
     class JavaScriptElementProxy &lt; JavaScriptProxy #:nodoc:
       def initialize(generator, id)
         @id = id
-        super(generator, &quot;$(#{id.to_json})&quot;)
+        super(generator, &quot;$(#{ActiveSupport::JSON.encode(id)})&quot;)
       end
 
       # Allows access of element attributes through +attribute+. Examples:
@@ -1184,7 +1184,7 @@ module ActionView
         true
       end
 
-      def to_json(options = nil)
+      def rails_to_json(options = nil)
         @variable
       end
 
@@ -1211,7 +1211,7 @@ module ActionView
           enumerate :eachSlice, :variable =&gt; variable, :method_args =&gt; [number], :yield_args =&gt; %w(value index), :return =&gt; true, &amp;block
         else
           add_variable_assignment!(variable)
-          append_enumerable_function!(&quot;eachSlice(#{number.to_json});&quot;)
+          append_enumerable_function!(&quot;eachSlice(#{ActiveSupport::JSON.encode(number)});&quot;)
         end
       end
 
@@ -1232,7 +1232,7 @@ module ActionView
 
       def pluck(variable, property)
         add_variable_assignment!(variable)
-        append_enumerable_function!(&quot;pluck(#{property.to_json});&quot;)
+        append_enumerable_function!(&quot;pluck(#{ActiveSupport::JSON.encode(property)});&quot;)
       end
 
       def zip(variable, *arguments, &amp;block)
@@ -1296,7 +1296,7 @@ module ActionView
 
     class JavaScriptElementCollectionProxy &lt; JavaScriptCollectionProxy #:nodoc:\
       def initialize(generator, pattern)
-        super(generator, &quot;$$(#{pattern.to_json})&quot;)
+        super(generator, &quot;$$(#{ActiveSupport::JSON.encode(pattern)})&quot;)
       end
     end
   end</diff>
      <filename>vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -43,7 +43,7 @@ module ActionView
       # You can change the behaviour with various options, see
       # http://script.aculo.us for more documentation.
       def visual_effect(name, element_id = false, js_options = {})
-        element = element_id ? element_id.to_json : &quot;element&quot;
+        element = element_id ? ActiveSupport::JSON.encode(element_id) : &quot;element&quot;
         
         js_options[:queue] = if js_options[:queue].is_a?(Hash)
           '{' + js_options[:queue].map {|k, v| k == :limit ? &quot;#{k}:#{v}&quot; : &quot;#{k}:'#{v}'&quot; }.join(',') + '}'
@@ -138,7 +138,7 @@ module ActionView
       end
       
       def sortable_element_js(element_id, options = {}) #:nodoc:
-        options[:with]     ||= &quot;Sortable.serialize(#{element_id.to_json})&quot;
+        options[:with]     ||= &quot;Sortable.serialize(#{ActiveSupport::JSON.encode(element_id)})&quot;
         options[:onUpdate] ||= &quot;function(){&quot; + remote_function(options) + &quot;}&quot;
         options.delete_if { |key, value| PrototypeHelper::AJAX_OPTIONS.include?(key) }
   
@@ -149,7 +149,7 @@ module ActionView
         options[:containment] = array_or_string_for_javascript(options[:containment]) if options[:containment]
         options[:only] = array_or_string_for_javascript(options[:only]) if options[:only]
   
-        %(Sortable.create(#{element_id.to_json}, #{options_for_javascript(options)});)
+        %(Sortable.create(#{ActiveSupport::JSON.encode(element_id)}, #{options_for_javascript(options)});)
       end
 
       # Makes the element with the DOM ID specified by +element_id+ draggable.
@@ -164,7 +164,7 @@ module ActionView
       end
       
       def draggable_element_js(element_id, options = {}) #:nodoc:
-        %(new Draggable(#{element_id.to_json}, #{options_for_javascript(options)});)
+        %(new Draggable(#{ActiveSupport::JSON.encode(element_id)}, #{options_for_javascript(options)});)
       end
 
       # Makes the element with the DOM ID specified by +element_id+ receive
@@ -219,7 +219,7 @@ module ActionView
         # Confirmation happens during the onDrop callback, so it can be removed from the options
         options.delete(:confirm) if options[:confirm]
 
-        %(Droppables.add(#{element_id.to_json}, #{options_for_javascript(options)});)
+        %(Droppables.add(#{ActiveSupport::JSON.encode(element_id)}, #{options_for_javascript(options)});)
       end
     end
   end</diff>
      <filename>vendor/rails/actionpack/lib/action_view/helpers/scriptaculous_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -61,7 +61,7 @@ module ActionView #:nodoc:
         end
       end
 
-      return Template.new(original_template_path, original_template_path =~ /\A\// ? &quot;&quot; : &quot;.&quot;) if File.file?(original_template_path)
+      return Template.new(original_template_path) if File.file?(original_template_path)
 
       raise MissingTemplate.new(self, original_template_path, format)
     end</diff>
      <filename>vendor/rails/actionpack/lib/action_view/paths.rb</filename>
    </modified>
    <modified>
      <diff>@@ -107,9 +107,8 @@ module ActionView #:nodoc:
     attr_accessor :locale, :name, :format, :extension
     delegate :to_s, :to =&gt; :path
 
-    def initialize(template_path, load_path)
-      @template_path = template_path.dup
-      @load_path, @filename = load_path, File.join(load_path, template_path)
+    def initialize(template_path, load_path = nil)
+      @template_path, @load_path = template_path.dup, load_path
       @base_path, @name, @locale, @format, @extension = split(template_path)
       @base_path.to_s.gsub!(/\/$/, '') # Push to split method
 
@@ -180,6 +179,12 @@ module ActionView #:nodoc:
       @@exempt_from_layout.any? { |exempted| path =~ exempted }
     end
 
+    def filename
+      # no load_path means this is an &quot;absolute pathed&quot; template
+      load_path ? File.join(load_path, template_path) : template_path
+    end
+    memoize :filename
+
     def source
       File.read(filename)
     end
@@ -212,46 +217,30 @@ module ActionView #:nodoc:
       end
 
       def valid_locale?(locale)
-        I18n.available_locales.include?(locale.to_sym)
+        locale &amp;&amp; I18n.available_locales.include?(locale.to_sym)
       end
 
       # Returns file split into an array
       #   [base_path, name, locale, format, extension]
       def split(file)
         if m = file.to_s.match(/^(.*\/)?([^\.]+)\.(.*)$/)
-          base_path = m[1]
-          name = m[2]
-          extensions = m[3]
-        else
-          return
+          [m[1], m[2], *parse_extensions(m[3])]
         end
+      end
 
-        locale = nil
-        format = nil
-        extension = nil
-
-        if m = extensions.split(&quot;.&quot;)
-          if valid_locale?(m[0]) &amp;&amp; m[1] &amp;&amp; valid_extension?(m[2]) # All three
-            locale = m[0]
-            format = m[1]
-            extension = m[2]
-          elsif m[0] &amp;&amp; m[1] &amp;&amp; valid_extension?(m[2]) # Multipart formats
-            format = &quot;#{m[0]}.#{m[1]}&quot;
-            extension = m[2]
-          elsif valid_locale?(m[0]) &amp;&amp; valid_extension?(m[1]) # locale and extension
-            locale = m[0]
-            extension = m[1]
-          elsif valid_extension?(m[1]) # format and extension
-            format = m[0]
-            extension = m[1]
-          elsif valid_extension?(m[0]) # Just extension
-            extension = m[0]
-          else # No extension
-            format = m[0]
-          end
+      # returns parsed extensions as an array
+      #   [locale, format, extension]
+      def parse_extensions(extensions)
+        exts = extensions.split(&quot;.&quot;)
+
+        if extension = valid_extension?(exts.last) &amp;&amp; exts.pop || nil
+          locale = valid_locale?(exts.first) &amp;&amp; exts.shift || nil
+          format = exts.join('.') if exts.any? # join('.') is needed for multipart templates
+        else # no extension, just format
+          format = exts.last
         end
 
-        [base_path, name, locale, format, extension]
+        [locale, format, extension]
       end
   end
 end</diff>
      <filename>vendor/rails/actionpack/lib/action_view/template.rb</filename>
    </modified>
    <modified>
      <diff>@@ -27,9 +27,9 @@ class ActiveRecordStoreTest &lt; ActionController::IntegrationTest
     end
 
     def call_reset_session
-      session[:bar]
+      session[:foo]
       reset_session
-      session[:bar] = &quot;baz&quot;
+      session[:foo] = &quot;baz&quot;
       head :ok
     end
 
@@ -86,7 +86,7 @@ class ActiveRecordStoreTest &lt; ActionController::IntegrationTest
 
       get '/get_session_value'
       assert_response :success
-      assert_equal 'foo: nil', response.body
+      assert_equal 'foo: &quot;baz&quot;', response.body
 
       get '/get_session_id'
       assert_response :success</diff>
      <filename>vendor/rails/actionpack/test/activerecord/active_record_store_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,6 +11,9 @@ class ActionPackAssertionsController &lt; ActionController::Base
 
   # a standard template
   def hello_xml_world() render :template =&gt; &quot;test/hello_xml_world&quot;; end
+  
+  # a standard partial
+  def partial() render :partial =&gt; 'test/partial'; end
 
   # a redirect to an internal location
   def redirect_internal() redirect_to &quot;/nothing&quot;; end
@@ -332,6 +335,30 @@ class ActionPackAssertionsControllerTest &lt; ActionController::TestCase
     assert @response.rendered[:template]
     assert 'hello_world', @response.rendered[:template].to_s
   end
+  
+  def test_assert_template_with_partial
+    get :partial
+    assert_template :partial =&gt; '_partial'
+  end
+  
+  def test_assert_template_with_nil
+    get :nothing
+    assert_template nil
+  end
+  
+  def test_assert_template_with_string
+    get :hello_world
+    assert_template 'hello_world'    
+  end
+  
+  def test_assert_template_with_symbol
+    get :hello_world
+    assert_template :hello_world
+  end
+  
+  def test_assert_template_with_bad_argument
+    assert_raise(ArgumentError) { assert_template 1 }    
+  end
 
   # check the redirection location
   def test_redirection_location</diff>
      <filename>vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,6 @@
 require 'fileutils'
 require 'abstract_unit'
+require 'active_record_unit'
 
 CACHE_DIR = 'test_cache'
 # Don't change '/../temp/' cavalierly or you might hose something you don't want hosed
@@ -7,6 +8,10 @@ FILE_STORE_PATH = File.join(File.dirname(__FILE__), '/../temp/', CACHE_DIR)
 ActionController::Base.page_cache_directory = FILE_STORE_PATH
 ActionController::Base.cache_store = :file_store, FILE_STORE_PATH
 
+# Force sweeper classes to load
+ActionController::Caching::Sweeper
+ActionController::Caching::Sweeping
+
 class PageCachingTestController &lt; ActionController::Base
   caches_page :ok, :no_content, :if =&gt; Proc.new { |c| !c.request.format.json? }
   caches_page :found, :not_found
@@ -152,6 +157,7 @@ class ActionCachingTestController &lt; ActionController::Base
   caches_action :edit, :cache_path =&gt; Proc.new { |c| c.params[:id] ? &quot;http://test.host/#{c.params[:id]};edit&quot; : &quot;http://test.host/edit&quot; }
   caches_action :with_layout
   caches_action :layout_false, :layout =&gt; false
+  caches_action :record_not_found, :four_oh_four, :simple_runtime_error
 
   layout 'talk_from_action.erb'
 
@@ -174,6 +180,18 @@ class ActionCachingTestController &lt; ActionController::Base
     render :text =&gt; @cache_this, :layout =&gt; true
   end
 
+  def record_not_found
+    raise ActiveRecord::RecordNotFound, &quot;oops!&quot;
+  end
+
+  def four_oh_four
+    render :text =&gt; &quot;404'd!&quot;, :status =&gt; 404
+  end
+
+  def simple_runtime_error
+    raise &quot;oops!&quot;
+  end
+
   alias_method :show, :index
   alias_method :edit, :index
   alias_method :destroy, :index
@@ -456,6 +474,27 @@ class ActionCacheTest &lt; ActionController::TestCase
     assert_response :success
   end
 
+  def test_record_not_found_returns_404_for_multiple_requests
+    get :record_not_found
+    assert_response 404
+    get :record_not_found
+    assert_response 404
+  end
+
+  def test_four_oh_four_returns_404_for_multiple_requests
+    get :four_oh_four
+    assert_response 404
+    get :four_oh_four
+    assert_response 404
+  end
+
+  def test_simple_runtime_error_returns_500_for_multiple_requests
+    get :simple_runtime_error
+    assert_response 500
+    get :simple_runtime_error
+    assert_response 500
+  end
+
   private
     def content_to_cache
       assigns(:cache_this)</diff>
      <filename>vendor/rails/actionpack/test/controller/caching_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,10 @@ class CookieTest &lt; ActionController::TestCase
       cookies[&quot;user_name&quot;] = &quot;david&quot;
     end
 
+    def set_with_with_escapable_characters
+      cookies[&quot;that &amp; guy&quot;] = &quot;foo &amp; bar =&gt; baz&quot;
+    end
+
     def authenticate_for_fourteen_days
       cookies[&quot;user_name&quot;] = { &quot;value&quot; =&gt; &quot;david&quot;, &quot;expires&quot; =&gt; Time.utc(2005, 10, 10,5) }
     end
@@ -53,6 +57,12 @@ class CookieTest &lt; ActionController::TestCase
     assert_equal({&quot;user_name&quot; =&gt; &quot;david&quot;}, @response.cookies)
   end
 
+  def test_setting_with_escapable_characters
+    get :set_with_with_escapable_characters
+    assert_equal [&quot;that+%26+guy=foo+%26+bar+%3D%3E+baz; path=/&quot;], @response.headers[&quot;Set-Cookie&quot;]
+    assert_equal({&quot;that &amp; guy&quot; =&gt; &quot;foo &amp; bar =&gt; baz&quot;}, @response.cookies)
+  end
+
   def test_setting_cookie_for_fourteen_days
     get :authenticate_for_fourteen_days
     assert_equal [&quot;user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT&quot;], @response.headers[&quot;Set-Cookie&quot;]</diff>
      <filename>vendor/rails/actionpack/test/controller/cookie_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -94,7 +94,7 @@ class DispatcherTest &lt; Test::Unit::TestCase
     def dispatch(cache_classes = true)
       ActionController::Routing::RouteSet.any_instance.stubs(:call).returns([200, {}, 'response'])
       Dispatcher.define_dispatcher_callbacks(cache_classes)
-      Dispatcher.new.call({})
+      Dispatcher.new.call({'rack.input' =&gt; StringIO.new('')})
     end
 
     def assert_subclasses(howmany, klass, message = klass.subclasses.inspect)</diff>
      <filename>vendor/rails/actionpack/test/controller/dispatcher_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -151,6 +151,16 @@ class HttpDigestAuthenticationTest &lt; ActionController::TestCase
     assert_equal 'Definitely Maybe', @response.body
   end
 
+  test &quot;authentication request with _method&quot; do
+    @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username =&gt; 'pretty', :password =&gt; 'please', :method =&gt; :post)
+    @request.env['rack.methodoverride.original_method'] = 'POST'
+    put :display
+
+    assert_response :success
+    assert assigns(:logged_in)
+    assert_equal 'Definitely Maybe', @response.body
+  end
+
   private
 
   def encode_credentials(options)
@@ -161,15 +171,22 @@ class HttpDigestAuthenticationTest &lt; ActionController::TestCase
     # to prevent tampering of timestamp
     ActionController::Base.session_options[:secret] = &quot;session_options_secret&quot;
 
-    # Perform unauthenticated GET to retrieve digest parameters to use on subsequent request
-    get :index
+    # Perform unauthenticated request to retrieve digest parameters to use on subsequent request
+    method = options.delete(:method) || 'GET'
+
+    case method.to_s.upcase
+    when 'GET'
+      get :index
+    when 'POST'
+      post :index
+    end
 
     assert_response :unauthorized
 
     credentials = decode_credentials(@response.headers['WWW-Authenticate'])
     credentials.merge!(options)
     credentials.reverse_merge!(:uri =&gt; &quot;#{@request.env['REQUEST_URI']}&quot;)
-    ActionController::HttpAuthentication::Digest.encode_credentials(&quot;GET&quot;, credentials, password, options[:password_is_ha1])
+    ActionController::HttpAuthentication::Digest.encode_credentials(method, credentials, password, options[:password_is_ha1])
   end
 
   def decode_credentials(header)</diff>
      <filename>vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@ require 'abstract_unit'
 
 class SessionTest &lt; Test::Unit::TestCase
   StubApp = lambda { |env|
-    [200, {&quot;Content-Type&quot; =&gt; &quot;text/html&quot;, &quot;Content-Length&quot; =&gt; &quot;13&quot;}, &quot;Hello, World!&quot;]
+    [200, {&quot;Content-Type&quot; =&gt; &quot;text/html&quot;, &quot;Content-Length&quot; =&gt; &quot;13&quot;}, [&quot;Hello, World!&quot;]]
   }
 
   def setup
@@ -389,9 +389,9 @@ class MetalTest &lt; ActionController::IntegrationTest
   class Poller
     def self.call(env)
       if env[&quot;PATH_INFO&quot;] =~ /^\/success/
-        [200, {&quot;Content-Type&quot; =&gt; &quot;text/plain&quot;, &quot;Content-Length&quot; =&gt; &quot;12&quot;}, &quot;Hello World!&quot;]
+        [200, {&quot;Content-Type&quot; =&gt; &quot;text/plain&quot;, &quot;Content-Length&quot; =&gt; &quot;12&quot;}, [&quot;Hello World!&quot;]]
       else
-        [404, {&quot;Content-Type&quot; =&gt; &quot;text/plain&quot;, &quot;Content-Length&quot; =&gt; &quot;0&quot;}, '']
+        [404, {&quot;Content-Type&quot; =&gt; &quot;text/plain&quot;, &quot;Content-Length&quot; =&gt; &quot;0&quot;}, []]
       end
     end
   end</diff>
      <filename>vendor/rails/actionpack/test/controller/integration_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -235,7 +235,10 @@ class RedirectTest &lt; ActionController::TestCase
 
   def test_redirect_with_partial_params
     get :module_redirect
-    assert_redirected_to :action =&gt; 'hello_world'
+
+    assert_deprecated do
+      assert_redirected_to :action =&gt; 'hello_world'
+    end
   end
 
   def test_redirect_to_nil</diff>
      <filename>vendor/rails/actionpack/test/controller/redirect_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -193,20 +193,24 @@ class TestController &lt; ActionController::Base
     render :inline =&gt;  &quot;&lt;%= controller_name %&gt;&quot;
   end
 
+  def render_json_nil
+    render :json =&gt; nil
+  end
+
   def render_json_hello_world
-    render :json =&gt; {:hello =&gt; 'world'}.to_json
+    render :json =&gt; ActiveSupport::JSON.encode(:hello =&gt; 'world')
   end
 
   def render_json_hello_world_with_callback
-    render :json =&gt; {:hello =&gt; 'world'}.to_json, :callback =&gt; 'alert'
+    render :json =&gt; ActiveSupport::JSON.encode(:hello =&gt; 'world'), :callback =&gt; 'alert'
   end
 
   def render_json_with_custom_content_type
-    render :json =&gt; {:hello =&gt; 'world'}.to_json, :content_type =&gt; 'text/javascript'
+    render :json =&gt; ActiveSupport::JSON.encode(:hello =&gt; 'world'), :content_type =&gt; 'text/javascript'
   end
 
   def render_symbol_json
-    render :json =&gt; {:hello =&gt; 'world'}.to_json
+    render :json =&gt; ActiveSupport::JSON.encode(:hello =&gt; 'world')
   end
 
   def render_json_with_render_to_string
@@ -886,33 +890,39 @@ class RenderTest &lt; ActionController::TestCase
     assert_equal &quot;The secret is in the sauce\n&quot;, @response.body
   end
 
+  def test_render_json_nil
+    get :render_json_nil
+    assert_equal 'null', @response.body
+    assert_equal 'application/json', @response.content_type
+  end
+
   def test_render_json
     get :render_json_hello_world
-    assert_equal '{&quot;hello&quot;: &quot;world&quot;}', @response.body
+    assert_equal '{&quot;hello&quot;:&quot;world&quot;}', @response.body
     assert_equal 'application/json', @response.content_type
   end
 
   def test_render_json_with_callback
     get :render_json_hello_world_with_callback
-    assert_equal 'alert({&quot;hello&quot;: &quot;world&quot;})', @response.body
+    assert_equal 'alert({&quot;hello&quot;:&quot;world&quot;})', @response.body
     assert_equal 'application/json', @response.content_type
   end
 
   def test_render_json_with_custom_content_type
     get :render_json_with_custom_content_type
-    assert_equal '{&quot;hello&quot;: &quot;world&quot;}', @response.body
+    assert_equal '{&quot;hello&quot;:&quot;world&quot;}', @response.body
     assert_equal 'text/javascript', @response.content_type
   end
 
   def test_render_symbol_json
     get :render_symbol_json
-    assert_equal '{&quot;hello&quot;: &quot;world&quot;}', @response.body
+    assert_equal '{&quot;hello&quot;:&quot;world&quot;}', @response.body
     assert_equal 'application/json', @response.content_type
   end
 
   def test_render_json_with_render_to_string
     get :render_json_with_render_to_string
-    assert_equal '{&quot;hello&quot;: &quot;partial html&quot;}', @response.body
+    assert_equal '{&quot;hello&quot;:&quot;partial html&quot;}', @response.body
     assert_equal 'application/json', @response.content_type
   end
 </diff>
      <filename>vendor/rails/actionpack/test/controller/render_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -96,7 +96,7 @@ class MultipartParamsParsingTest &lt; ActionController::IntegrationTest
 
     # Ruby CGI doesn't handle multipart/mixed for us.
     files = params['files']
-    assert_kind_of String, files
+    assert_kind_of Tempfile, files
     files.force_encoding('ASCII-8BIT') if files.respond_to?(:force_encoding)
     assert_equal 19756, files.size
   end
@@ -133,46 +133,6 @@ class MultipartParamsParsingTest &lt; ActionController::IntegrationTest
     end
   end
 
-  # The lint wrapper is used in integration tests
-  # instead of a normal StringIO class
-  InputWrapper = Rack::Lint::InputWrapper
-
-  test &quot;parses unwindable stream&quot; do
-    InputWrapper.any_instance.stubs(:rewind).raises(Errno::ESPIPE)
-    params = parse_multipart('large_text_file')
-    assert_equal %w(file foo), params.keys.sort
-    assert_equal 'bar', params['foo']
-  end
-
-  test &quot;uploads and reads file with unwindable input&quot; do
-    InputWrapper.any_instance.stubs(:rewind).raises(Errno::ESPIPE)
-
-    with_test_routing do
-      post '/read', :uploaded_data =&gt; fixture_file_upload(FIXTURE_PATH + &quot;/hello.txt&quot;, &quot;text/plain&quot;)
-      assert_equal &quot;File: Hello&quot;, response.body
-    end
-  end
-
-  test &quot;passes through rack middleware and uploads file&quot; do
-    with_muck_middleware do
-      with_test_routing do
-        post '/read', :uploaded_data =&gt; fixture_file_upload(FIXTURE_PATH + &quot;/hello.txt&quot;, &quot;text/plain&quot;)
-        assert_equal &quot;File: Hello&quot;, response.body
-      end
-    end
-  end
-
-  test &quot;passes through rack middleware and uploads file with unwindable input&quot; do
-    InputWrapper.any_instance.stubs(:rewind).raises(Errno::ESPIPE)
-
-    with_muck_middleware do
-      with_test_routing do
-        post '/read', :uploaded_data =&gt; fixture_file_upload(FIXTURE_PATH + &quot;/hello.txt&quot;, &quot;text/plain&quot;)
-        assert_equal &quot;File: Hello&quot;, response.body
-      end
-    end
-  end
-
   private
     def fixture(name)
       File.open(File.join(FIXTURE_PATH, name), 'rb') do |file|
@@ -199,25 +159,4 @@ class MultipartParamsParsingTest &lt; ActionController::IntegrationTest
         yield
       end
     end
-
-    class MuckMiddleware
-      def initialize(app)
-        @app = app
-      end
-
-      def call(env)
-        req = Rack::Request.new(env)
-        req.params # Parse params
-        @app.call(env)
-      end
-    end
-
-    def with_muck_middleware
-      original_middleware = ActionController::Dispatcher.middleware
-      middleware = original_middleware.dup
-      middleware.insert_after ActionController::RewindableInput, MuckMiddleware
-      ActionController::Dispatcher.middleware = middleware
-      yield
-      ActionController::Dispatcher.middleware = original_middleware
-    end
 end</diff>
      <filename>vendor/rails/actionpack/test/controller/request/multipart_params_parsing_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -126,45 +126,7 @@ class UrlEncodedParamsParsingTest &lt; ActionController::IntegrationTest
     assert_parses expected, query
   end
 
-  test &quot;passes through rack middleware and parses params&quot; do
-    with_muck_middleware do
-      assert_parses({ &quot;a&quot; =&gt; { &quot;b&quot; =&gt; &quot;c&quot; } }, &quot;a[b]=c&quot;)
-    end
-  end
-
-  # The lint wrapper is used in integration tests
-  # instead of a normal StringIO class
-  InputWrapper = Rack::Lint::InputWrapper
-
-  test &quot;passes through rack middleware and parses params with unwindable input&quot; do
-    InputWrapper.any_instance.stubs(:rewind).raises(Errno::ESPIPE)
-    with_muck_middleware do
-      assert_parses({ &quot;a&quot; =&gt; { &quot;b&quot; =&gt; &quot;c&quot; } }, &quot;a[b]=c&quot;)
-    end
-  end
-
   private
-    class MuckMiddleware
-      def initialize(app)
-        @app = app
-      end
-
-      def call(env)
-        req = Rack::Request.new(env)
-        req.params # Parse params
-        @app.call(env)
-      end
-    end
-
-    def with_muck_middleware
-      original_middleware = ActionController::Dispatcher.middleware
-      middleware = original_middleware.dup
-      middleware.insert_after ActionController::RewindableInput, MuckMiddleware
-      ActionController::Dispatcher.middleware = middleware
-      yield
-      ActionController::Dispatcher.middleware = original_middleware
-    end
-
     def with_test_routing
       with_routing do |set|
         set.draw do |map|</diff>
      <filename>vendor/rails/actionpack/test/controller/request/url_encoded_params_parsing_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,6 @@ require 'abstract_unit'
 class RequestTest &lt; ActiveSupport::TestCase
   def setup
     ActionController::Base.relative_url_root = nil
-    @request = ActionController::TestRequest.new
   end
 
   def teardown
@@ -11,60 +10,52 @@ class RequestTest &lt; ActiveSupport::TestCase
   end
 
   def test_remote_ip
-    assert_equal '0.0.0.0', @request.remote_ip
+    request = stub_request 'REMOTE_ADDR' =&gt; '1.2.3.4'
+    assert_equal '1.2.3.4', request.remote_ip
 
-    @request.remote_addr = '1.2.3.4'
-    assert_equal '1.2.3.4', @request.remote_ip
+    request = stub_request 'REMOTE_ADDR' =&gt; '1.2.3.4,3.4.5.6'
+    assert_equal '1.2.3.4', request.remote_ip
 
-    @request.remote_addr = '1.2.3.4,3.4.5.6'
-    assert_equal '1.2.3.4', @request.remote_ip
+    request = stub_request 'REMOTE_ADDR' =&gt; '1.2.3.4',
+      'HTTP_X_FORWARDED_FOR' =&gt; '3.4.5.6'
+    assert_equal '1.2.3.4', request.remote_ip
 
-    @request.env['HTTP_CLIENT_IP'] = '2.3.4.5'
-    assert_equal '1.2.3.4', @request.remote_ip
+    request = stub_request 'REMOTE_ADDR' =&gt; '127.0.0.1',
+      'HTTP_X_FORWARDED_FOR' =&gt; '3.4.5.6'
+    assert_equal '3.4.5.6', request.remote_ip
 
-    @request.remote_addr = '192.168.0.1'
-    assert_equal '2.3.4.5', @request.remote_ip
-    @request.env.delete 'HTTP_CLIENT_IP'
+    request = stub_request 'HTTP_X_FORWARDED_FOR' =&gt; 'unknown,3.4.5.6'
+    assert_equal '3.4.5.6', request.remote_ip
 
-    @request.remote_addr = '1.2.3.4'
-    @request.env['HTTP_X_FORWARDED_FOR'] = '3.4.5.6'
-    assert_equal '1.2.3.4', @request.remote_ip
+    request = stub_request 'HTTP_X_FORWARDED_FOR' =&gt; '172.16.0.1,3.4.5.6'
+    assert_equal '3.4.5.6', request.remote_ip
 
-    @request.remote_addr = '127.0.0.1'
-    @request.env['HTTP_X_FORWARDED_FOR'] = '3.4.5.6'
-    assert_equal '3.4.5.6', @request.remote_ip
+    request = stub_request 'HTTP_X_FORWARDED_FOR' =&gt; '192.168.0.1,3.4.5.6'
+    assert_equal '3.4.5.6', request.remote_ip
 
-    @request.env['HTTP_X_FORWARDED_FOR'] = 'unknown,3.4.5.6'
-    assert_equal '3.4.5.6', @request.remote_ip
+    request = stub_request 'HTTP_X_FORWARDED_FOR' =&gt; '10.0.0.1,3.4.5.6'
+    assert_equal '3.4.5.6', request.remote_ip
 
-    @request.env['HTTP_X_FORWARDED_FOR'] = '172.16.0.1,3.4.5.6'
-    assert_equal '3.4.5.6', @request.remote_ip
+    request = stub_request 'HTTP_X_FORWARDED_FOR' =&gt; '10.0.0.1, 10.0.0.1, 3.4.5.6'
+    assert_equal '3.4.5.6', request.remote_ip
 
-    @request.env['HTTP_X_FORWARDED_FOR'] = '192.168.0.1,3.4.5.6'
-    assert_equal '3.4.5.6', @request.remote_ip
+    request = stub_request 'HTTP_X_FORWARDED_FOR' =&gt; '127.0.0.1,3.4.5.6'
+    assert_equal '3.4.5.6', request.remote_ip
 
-    @request.env['HTTP_X_FORWARDED_FOR'] = '10.0.0.1,3.4.5.6'
-    assert_equal '3.4.5.6', @request.remote_ip
+    request = stub_request 'HTTP_X_FORWARDED_FOR' =&gt; 'unknown,192.168.0.1'
+    assert_equal 'unknown', request.remote_ip
 
-    @request.env['HTTP_X_FORWARDED_FOR'] = '10.0.0.1, 10.0.0.1, 3.4.5.6'
-    assert_equal '3.4.5.6', @request.remote_ip
+    request = stub_request 'HTTP_X_FORWARDED_FOR' =&gt; '9.9.9.9, 3.4.5.6, 10.0.0.1, 172.31.4.4'
+    assert_equal '3.4.5.6', request.remote_ip
 
-    @request.env['HTTP_X_FORWARDED_FOR'] = '127.0.0.1,3.4.5.6'
-    assert_equal '3.4.5.6', @request.remote_ip
-
-    @request.env['HTTP_X_FORWARDED_FOR'] = 'unknown,192.168.0.1'
-    assert_equal 'unknown', @request.remote_ip
-
-    @request.env['HTTP_X_FORWARDED_FOR'] = '9.9.9.9, 3.4.5.6, 10.0.0.1, 172.31.4.4'
-    assert_equal '3.4.5.6', @request.remote_ip
-
-    @request.env['HTTP_CLIENT_IP'] = '8.8.8.8'
+    request = stub_request 'HTTP_X_FORWARDED_FOR' =&gt; '1.1.1.1',
+                           'HTTP_CLIENT_IP'       =&gt; '2.2.2.2'
     e = assert_raise(ActionController::ActionControllerError) {
-      @request.remote_ip
+      request.remote_ip
     }
     assert_match /IP spoofing attack/, e.message
-    assert_match /HTTP_X_FORWARDED_FOR=&quot;9.9.9.9, 3.4.5.6, 10.0.0.1, 172.31.4.4&quot;/, e.message
-    assert_match /HTTP_CLIENT_IP=&quot;8.8.8.8&quot;/, e.message
+    assert_match /HTTP_X_FORWARDED_FOR=&quot;1.1.1.1&quot;/, e.message
+    assert_match /HTTP_CLIENT_IP=&quot;2.2.2.2&quot;/, e.message
 
     # turn IP Spoofing detection off.
     # This is useful for sites that are aimed at non-IP clients.  The typical
@@ -72,336 +63,333 @@ class RequestTest &lt; ActiveSupport::TestCase
     # leap of faith to assume that their proxies are ever going to set the
     # HTTP_CLIENT_IP/HTTP_X_FORWARDED_FOR headers properly.
     ActionController::Base.ip_spoofing_check = false
-    assert_equal('8.8.8.8', @request.remote_ip)
+    request = stub_request 'HTTP_X_FORWARDED_FOR' =&gt; '1.1.1.1',
+                           'HTTP_CLIENT_IP'       =&gt; '2.2.2.2'
+    assert_equal '2.2.2.2', request.remote_ip
     ActionController::Base.ip_spoofing_check = true
 
-    @request.env['HTTP_X_FORWARDED_FOR'] = '8.8.8.8, 9.9.9.9'
-    assert_equal '8.8.8.8', @request.remote_ip
-
-    @request.env.delete 'HTTP_CLIENT_IP'
-    @request.env.delete 'HTTP_X_FORWARDED_FOR'
+    request = stub_request 'HTTP_X_FORWARDED_FOR' =&gt; '8.8.8.8, 9.9.9.9'
+    assert_equal '9.9.9.9', request.remote_ip
   end
 
   def test_domains
-    @request.host = &quot;www.rubyonrails.org&quot;
-    assert_equal &quot;rubyonrails.org&quot;, @request.domain
-
-    @request.host = &quot;www.rubyonrails.co.uk&quot;
-    assert_equal &quot;rubyonrails.co.uk&quot;, @request.domain(2)
+    request = stub_request 'HTTP_HOST' =&gt; 'www.rubyonrails.org'
+    assert_equal &quot;rubyonrails.org&quot;, request.domain
 
-    @request.host = &quot;192.168.1.200&quot;
-    assert_nil @request.domain
+    request = stub_request 'HTTP_HOST' =&gt; &quot;www.rubyonrails.co.uk&quot;
+    assert_equal &quot;rubyonrails.co.uk&quot;, request.domain(2)
 
-    @request.host = &quot;foo.192.168.1.200&quot;
-    assert_nil @request.domain
+    request = stub_request 'HTTP_HOST' =&gt; &quot;192.168.1.200&quot;
+    assert_nil request.domain
 
-    @request.host = &quot;192.168.1.200.com&quot;
-    assert_equal &quot;200.com&quot;, @request.domain
+    request = stub_request 'HTTP_HOST' =&gt; &quot;foo.192.168.1.200&quot;
+    assert_nil request.domain
 
-    @request.host = nil
-    assert_nil @request.domain
+    request = stub_request 'HTTP_HOST' =&gt; &quot;192.168.1.200.com&quot;
+    assert_equal &quot;200.com&quot;, request.domain
   end
 
   def test_subdomains
-    @request.host = &quot;www.rubyonrails.org&quot;
-    assert_equal %w( www ), @request.subdomains
+    request = stub_request 'HTTP_HOST' =&gt; &quot;www.rubyonrails.org&quot;
+    assert_equal %w( www ), request.subdomains
 
-    @request.host = &quot;www.rubyonrails.co.uk&quot;
-    assert_equal %w( www ), @request.subdomains(2)
+    request = stub_request 'HTTP_HOST' =&gt; &quot;www.rubyonrails.co.uk&quot;
+    assert_equal %w( www ), request.subdomains(2)
 
-    @request.host = &quot;dev.www.rubyonrails.co.uk&quot;
-    assert_equal %w( dev www ), @request.subdomains(2)
+    request = stub_request 'HTTP_HOST' =&gt; &quot;dev.www.rubyonrails.co.uk&quot;
+    assert_equal %w( dev www ), request.subdomains(2)
 
-    @request.host = &quot;foobar.foobar.com&quot;
-    assert_equal %w( foobar ), @request.subdomains
+    request = stub_request 'HTTP_HOST' =&gt; &quot;foobar.foobar.com&quot;
+    assert_equal %w( foobar ), request.subdomains
 
-    @request.host = &quot;192.168.1.200&quot;
-    assert_equal [], @request.subdomains
+    request = stub_request 'HTTP_HOST' =&gt; &quot;192.168.1.200&quot;
+    assert_equal [], request.subdomains
 
-    @request.host = &quot;foo.192.168.1.200&quot;
-    assert_equal [], @request.subdomains
+    request = stub_request 'HTTP_HOST' =&gt; &quot;foo.192.168.1.200&quot;
+    assert_equal [], request.subdomains
 
-    @request.host = &quot;192.168.1.200.com&quot;
-    assert_equal %w( 192 168 1 ), @request.subdomains
+    request = stub_request 'HTTP_HOST' =&gt; &quot;192.168.1.200.com&quot;
+    assert_equal %w( 192 168 1 ), request.subdomains
 
-    @request.host = nil
-    assert_equal [], @request.subdomains
+    request = stub_request 'HTTP_HOST' =&gt; nil
+    assert_equal [], request.subdomains
   end
 
   def test_port_string
-    @request.port = 80
-    assert_equal &quot;&quot;, @request.port_string
+    request = stub_request 'HTTP_HOST' =&gt; 'www.example.org:80'
+    assert_equal &quot;&quot;, request.port_string
 
-    @request.port = 8080
-    assert_equal &quot;:8080&quot;, @request.port_string
+    request = stub_request 'HTTP_HOST' =&gt; 'www.example.org:8080'
+    assert_equal &quot;:8080&quot;, request.port_string
   end
 
   def test_request_uri
-    @request.env['SERVER_SOFTWARE'] = 'Apache 42.342.3432'
+    request = stub_request 'REQUEST_URI' =&gt; &quot;http://www.rubyonrails.org/path/of/some/uri?mapped=1&quot;
+    assert_equal &quot;/path/of/some/uri?mapped=1&quot;, request.request_uri
+    assert_equal &quot;/path/of/some/uri&quot;,          request.path
 
-    @request.set_REQUEST_URI &quot;http://www.rubyonrails.org/path/of/some/uri?mapped=1&quot;
-    assert_equal &quot;/path/of/some/uri?mapped=1&quot;, @request.request_uri
-    assert_equal &quot;/path/of/some/uri&quot;, @request.path
+    request = stub_request 'REQUEST_URI' =&gt; &quot;http://www.rubyonrails.org/path/of/some/uri&quot;
+    assert_equal &quot;/path/of/some/uri&quot;, request.request_uri
+    assert_equal &quot;/path/of/some/uri&quot;, request.path
 
-    @request.set_REQUEST_URI &quot;http://www.rubyonrails.org/path/of/some/uri&quot;
-    assert_equal &quot;/path/of/some/uri&quot;, @request.request_uri
-    assert_equal &quot;/path/of/some/uri&quot;, @request.path
+    request = stub_request 'REQUEST_URI' =&gt; &quot;/path/of/some/uri&quot;
+    assert_equal &quot;/path/of/some/uri&quot;, request.request_uri
+    assert_equal &quot;/path/of/some/uri&quot;, request.path
 
-    @request.set_REQUEST_URI &quot;/path/of/some/uri&quot;
-    assert_equal &quot;/path/of/some/uri&quot;, @request.request_uri
-    assert_equal &quot;/path/of/some/uri&quot;, @request.path
+    request = stub_request 'REQUEST_URI' =&gt; &quot;/&quot;
+    assert_equal &quot;/&quot;, request.request_uri
+    assert_equal &quot;/&quot;, request.path
 
-    @request.set_REQUEST_URI &quot;/&quot;
-    assert_equal &quot;/&quot;, @request.request_uri
-    assert_equal &quot;/&quot;, @request.path
+    request = stub_request 'REQUEST_URI' =&gt; &quot;/?m=b&quot;
+    assert_equal &quot;/?m=b&quot;, request.request_uri
+    assert_equal &quot;/&quot;,     request.path
 
-    @request.set_REQUEST_URI &quot;/?m=b&quot;
-    assert_equal &quot;/?m=b&quot;, @request.request_uri
-    assert_equal &quot;/&quot;, @request.path
-
-    @request.set_REQUEST_URI &quot;/&quot;
-    @request.env['SCRIPT_NAME'] = &quot;/dispatch.cgi&quot;
-    assert_equal &quot;/&quot;, @request.request_uri
-    assert_equal &quot;/&quot;, @request.path
+    request = stub_request 'REQUEST_URI' =&gt; &quot;/&quot;, 'SCRIPT_NAME' =&gt; '/dispatch.cgi'
+    assert_equal &quot;/&quot;, request.request_uri
+    assert_equal &quot;/&quot;, request.path
 
     ActionController::Base.relative_url_root = &quot;/hieraki&quot;
-    @request.set_REQUEST_URI &quot;/hieraki/&quot;
-    @request.env['SCRIPT_NAME'] = &quot;/hieraki/dispatch.cgi&quot;
-    assert_equal &quot;/hieraki/&quot;, @request.request_uri
-    assert_equal &quot;/&quot;, @request.path
+    request = stub_request 'REQUEST_URI' =&gt; &quot;/hieraki/&quot;, 'SCRIPT_NAME' =&gt; &quot;/hieraki/dispatch.cgi&quot;
+    assert_equal &quot;/hieraki/&quot;, request.request_uri
+    assert_equal &quot;/&quot;,         request.path
     ActionController::Base.relative_url_root = nil
 
     ActionController::Base.relative_url_root = &quot;/collaboration/hieraki&quot;
-    @request.set_REQUEST_URI &quot;/collaboration/hieraki/books/edit/2&quot;
-    @request.env['SCRIPT_NAME'] = &quot;/collaboration/hieraki/dispatch.cgi&quot;
-    assert_equal &quot;/collaboration/hieraki/books/edit/2&quot;, @request.request_uri
-    assert_equal &quot;/books/edit/2&quot;, @request.path
+    request = stub_request 'REQUEST_URI' =&gt; &quot;/collaboration/hieraki/books/edit/2&quot;,
+      'SCRIPT_NAME' =&gt; &quot;/collaboration/hieraki/dispatch.cgi&quot;
+    assert_equal &quot;/collaboration/hieraki/books/edit/2&quot;, request.request_uri
+    assert_equal &quot;/books/edit/2&quot;,                       request.path
     ActionController::Base.relative_url_root = nil
 
     # The following tests are for when REQUEST_URI is not supplied (as in IIS)
-    @request.env['PATH_INFO'] = &quot;/path/of/some/uri?mapped=1&quot;
-    @request.env['SCRIPT_NAME'] = nil #&quot;/path/dispatch.rb&quot;
-    @request.set_REQUEST_URI nil
-    assert_equal &quot;/path/of/some/uri?mapped=1&quot;, @request.request_uri
-    assert_equal &quot;/path/of/some/uri&quot;, @request.path
+    request = stub_request 'PATH_INFO'   =&gt; &quot;/path/of/some/uri?mapped=1&quot;,
+                           'SCRIPT_NAME' =&gt; nil,
+                           'REQUEST_URI' =&gt; nil
+    assert_equal &quot;/path/of/some/uri?mapped=1&quot;, request.request_uri
+    assert_equal &quot;/path/of/some/uri&quot;,          request.path
 
     ActionController::Base.relative_url_root = '/path'
-    @request.env['PATH_INFO'] = &quot;/path/of/some/uri?mapped=1&quot;
-    @request.env['SCRIPT_NAME'] = &quot;/path/dispatch.rb&quot;
-    @request.set_REQUEST_URI nil
-    assert_equal &quot;/path/of/some/uri?mapped=1&quot;, @request.request_uri
-    assert_equal &quot;/of/some/uri&quot;, @request.path
+    request = stub_request 'PATH_INFO'   =&gt; &quot;/path/of/some/uri?mapped=1&quot;,
+                           'SCRIPT_NAME' =&gt; &quot;/path/dispatch.rb&quot;,
+                           'REQUEST_URI' =&gt; nil
+    assert_equal &quot;/path/of/some/uri?mapped=1&quot;, request.request_uri
+    assert_equal &quot;/of/some/uri&quot;,               request.path
     ActionController::Base.relative_url_root = nil
 
-    @request.env['PATH_INFO'] = &quot;/path/of/some/uri&quot;
-    @request.env['SCRIPT_NAME'] = nil
-    @request.set_REQUEST_URI nil
-    assert_equal &quot;/path/of/some/uri&quot;, @request.request_uri
-    assert_equal &quot;/path/of/some/uri&quot;, @request.path
+    request = stub_request 'PATH_INFO'   =&gt; &quot;/path/of/some/uri&quot;,
+                           'SCRIPT_NAME' =&gt; nil,
+                           'REQUEST_URI' =&gt; nil
+    assert_equal &quot;/path/of/some/uri&quot;, request.request_uri
+    assert_equal &quot;/path/of/some/uri&quot;, request.path
 
-    @request.env['PATH_INFO'] = &quot;/&quot;
-    @request.set_REQUEST_URI nil
-    assert_equal &quot;/&quot;, @request.request_uri
-    assert_equal &quot;/&quot;, @request.path
+    request = stub_request 'PATH_INFO' =&gt; '/', 'REQUEST_URI' =&gt; nil
+    assert_equal &quot;/&quot;, request.request_uri
+    assert_equal &quot;/&quot;, request.path
 
-    @request.env['PATH_INFO'] = &quot;/?m=b&quot;
-    @request.set_REQUEST_URI nil
-    assert_equal &quot;/?m=b&quot;, @request.request_uri
-    assert_equal &quot;/&quot;, @request.path
+    request = stub_request 'PATH_INFO' =&gt; '/?m=b', 'REQUEST_URI' =&gt; nil
+    assert_equal &quot;/?m=b&quot;, request.request_uri
+    assert_equal &quot;/&quot;,     request.path
 
-    @request.env['PATH_INFO'] = &quot;/&quot;
-    @request.env['SCRIPT_NAME'] = &quot;/dispatch.cgi&quot;
-    @request.set_REQUEST_URI nil
-    assert_equal &quot;/&quot;, @request.request_uri
-    assert_equal &quot;/&quot;, @request.path
+    request = stub_request 'PATH_INFO'   =&gt; &quot;/&quot;,
+                           'SCRIPT_NAME' =&gt; &quot;/dispatch.cgi&quot;,
+                           'REQUEST_URI' =&gt; nil
+    assert_equal &quot;/&quot;, request.request_uri
+    assert_equal &quot;/&quot;, request.path
 
     ActionController::Base.relative_url_root = '/hieraki'
-    @request.env['PATH_INFO'] = &quot;/hieraki/&quot;
-    @request.env['SCRIPT_NAME'] = &quot;/hieraki/dispatch.cgi&quot;
-    @request.set_REQUEST_URI nil
-    assert_equal &quot;/hieraki/&quot;, @request.request_uri
-    assert_equal &quot;/&quot;, @request.path
+    request = stub_request 'PATH_INFO'   =&gt; &quot;/hieraki/&quot;,
+                           'SCRIPT_NAME' =&gt; &quot;/hieraki/dispatch.cgi&quot;,
+                           'REQUEST_URI' =&gt; nil
+    assert_equal &quot;/hieraki/&quot;, request.request_uri
+    assert_equal &quot;/&quot;,         request.path
     ActionController::Base.relative_url_root = nil
 
-    @request.set_REQUEST_URI '/hieraki/dispatch.cgi'
+    request = stub_request 'REQUEST_URI' =&gt; '/hieraki/dispatch.cgi'
     ActionController::Base.relative_url_root = '/hieraki'
-    assert_equal &quot;/dispatch.cgi&quot;, @request.path
+    assert_equal &quot;/dispatch.cgi&quot;, request.path
     ActionController::Base.relative_url_root = nil
 
-    @request.set_REQUEST_URI '/hieraki/dispatch.cgi'
+    request = stub_request 'REQUEST_URI' =&gt; '/hieraki/dispatch.cgi'
     ActionController::Base.relative_url_root = '/foo'
-    assert_equal &quot;/hieraki/dispatch.cgi&quot;, @request.path
+    assert_equal &quot;/hieraki/dispatch.cgi&quot;, request.path
     ActionController::Base.relative_url_root = nil
 
     # This test ensures that Rails uses REQUEST_URI over PATH_INFO
     ActionController::Base.relative_url_root = nil
-    @request.env['REQUEST_URI'] = &quot;/some/path&quot;
-    @request.env['PATH_INFO'] = &quot;/another/path&quot;
-    @request.env['SCRIPT_NAME'] = &quot;/dispatch.cgi&quot;
-    assert_equal &quot;/some/path&quot;, @request.request_uri
-    assert_equal &quot;/some/path&quot;, @request.path
+    request = stub_request 'REQUEST_URI' =&gt; &quot;/some/path&quot;,
+                           'PATH_INFO'   =&gt; &quot;/another/path&quot;,
+                           'SCRIPT_NAME' =&gt; &quot;/dispatch.cgi&quot;
+    assert_equal &quot;/some/path&quot;, request.request_uri
+    assert_equal &quot;/some/path&quot;, request.path
   end
 
   def test_host_with_default_port
-    @request.host = &quot;rubyonrails.org&quot;
-    @request.port = 80
-    assert_equal &quot;rubyonrails.org&quot;, @request.host_with_port
+    request = stub_request 'HTTP_HOST' =&gt; 'rubyonrails.org:80'
+    assert_equal &quot;rubyonrails.org&quot;, request.host_with_port
   end
 
   def test_host_with_non_default_port
-    @request.host = &quot;rubyonrails.org&quot;
-    @request.port = 81
-    assert_equal &quot;rubyonrails.org:81&quot;, @request.host_with_port
+    request = stub_request 'HTTP_HOST' =&gt; 'rubyonrails.org:81'
+    assert_equal &quot;rubyonrails.org:81&quot;, request.host_with_port
   end
 
   def test_server_software
-    assert_equal nil, @request.server_software
+    request = stub_request
+    assert_equal nil, request.server_software
 
-    @request.env['SERVER_SOFTWARE'] = 'Apache3.422'
-    assert_equal 'apache', @request.server_software
+    request = stub_request 'SERVER_SOFTWARE' =&gt; 'Apache3.422'
+    assert_equal 'apache', request.server_software
 
-    @request.env['SERVER_SOFTWARE'] = 'lighttpd(1.1.4)'
-    assert_equal 'lighttpd', @request.server_software
+    request = stub_request 'SERVER_SOFTWARE' =&gt; 'lighttpd(1.1.4)'
+    assert_equal 'lighttpd', request.server_software
   end
 
   def test_xml_http_request
-    assert !@request.xml_http_request?
-    assert !@request.xhr?
+    request = stub_request
+
+    assert !request.xml_http_request?
+    assert !request.xhr?
 
-    @request.env['HTTP_X_REQUESTED_WITH'] = &quot;DefinitelyNotAjax1.0&quot;
-    assert !@request.xml_http_request?
-    assert !@request.xhr?
+    request = stub_request 'HTTP_X_REQUESTED_WITH' =&gt; 'DefinitelyNotAjax1.0'
+    assert !request.xml_http_request?
+    assert !request.xhr?
 
-    @request.env['HTTP_X_REQUESTED_WITH'] = &quot;XMLHttpRequest&quot;
-    assert @request.xml_http_request?
-    assert @request.xhr?
+    request = stub_request 'HTTP_X_REQUESTED_WITH' =&gt; 'XMLHttpRequest'
+    assert request.xml_http_request?
+    assert request.xhr?
   end
 
   def test_reports_ssl
-    assert !@request.ssl?
-    @request.env['HTTPS'] = 'on'
-    assert @request.ssl?
+    request = stub_request
+    assert !request.ssl?
+
+    request = stub_request 'HTTPS' =&gt; 'on'
+    assert request.ssl?
   end
 
   def test_reports_ssl_when_proxied_via_lighttpd
-    assert !@request.ssl?
-    @request.env['HTTP_X_FORWARDED_PROTO'] = 'https'
-    assert @request.ssl?
+    request = stub_request
+    assert !request.ssl?
+
+    request = stub_request 'HTTP_X_FORWARDED_PROTO' =&gt; 'https'
+    assert request.ssl?
   end
 
   def test_symbolized_request_methods
     [:get, :post, :put, :delete].each do |method|
-      self.request_method = method
-      assert_equal method, @request.method
+      request = stub_request 'REQUEST_METHOD' =&gt; method.to_s.upcase
+      assert_equal method, request.method
     end
   end
 
   def test_invalid_http_method_raises_exception
     assert_raise(ActionController::UnknownHttpMethod) do
-      self.request_method = :random_method
-      @request.request_method
+      request = stub_request 'REQUEST_METHOD' =&gt; 'RANDOM_METHOD'
+      request.request_method
     end
   end
 
   def test_allow_method_hacking_on_post
     [:get, :head, :options, :put, :post, :delete].each do |method|
-      self.request_method = method
-      assert_equal(method == :head ? :get : method, @request.method)
-    end
-  end
-
-  def test_invalid_method_hacking_on_post_raises_exception
-    assert_raise(ActionController::UnknownHttpMethod) do
-      self.request_method = :_random_method
-      @request.request_method
+      request = stub_request 'REQUEST_METHOD' =&gt; method.to_s.upcase
+      assert_equal(method == :head ? :get : method, request.method)
     end
   end
 
   def test_restrict_method_hacking
-    @request.instance_eval { @parameters = { :_method =&gt; 'put' } }
     [:get, :put, :delete].each do |method|
-      self.request_method = method
-      assert_equal method, @request.method
+      request = stub_request 'REQUEST_METHOD' =&gt; method.to_s.upcase,
+        'action_controller.request.request_parameters' =&gt; { :_method =&gt; 'put' }
+      assert_equal method, request.method
     end
   end
 
   def test_head_masquerading_as_get
-    self.request_method = :head
-    assert_equal :get, @request.method
-    assert @request.get?
-    assert @request.head?
+    request = stub_request 'REQUEST_METHOD' =&gt; 'HEAD'
+    assert_equal :get, request.method
+    assert request.get?
+    assert request.head?
   end
 
   def test_xml_format
-    @request.instance_eval { @parameters = { :format =&gt; 'xml' } }
-    assert_equal Mime::XML, @request.format
+    request = stub_request
+    request.expects(:parameters).at_least_once.returns({ :format =&gt; 'xml' })
+    assert_equal Mime::XML, request.format
   end
 
   def test_xhtml_format
-    @request.instance_eval { @parameters = { :format =&gt; 'xhtml' } }
-    assert_equal Mime::HTML, @request.format
+    request = stub_request
+    request.expects(:parameters).at_least_once.returns({ :format =&gt; 'xhtml' })
+    assert_equal Mime::HTML, request.format
   end
 
   def test_txt_format
-    @request.instance_eval { @parameters = { :format =&gt; 'txt' } }
-    assert_equal Mime::TEXT, @request.format
+    request = stub_request
+    request.expects(:parameters).at_least_once.returns({ :format =&gt; 'txt' })
+    assert_equal Mime::TEXT, request.format
   end
 
-  def test_nil_format
+  def test_xml_http_request
     ActionController::Base.use_accept_header, old =
       false, ActionController::Base.use_accept_header
 
-    @request.instance_eval { @parameters = {} }
-    @request.env[&quot;HTTP_X_REQUESTED_WITH&quot;] = &quot;XMLHttpRequest&quot;
-    assert @request.xhr?
-    assert_equal Mime::JS, @request.format
-
+    request = stub_request 'HTTP_X_REQUESTED_WITH' =&gt; 'XMLHttpRequest'
+    request.expects(:parameters).at_least_once.returns({})
+    assert request.xhr?
+    assert_equal Mime::JS, request.format
   ensure
     ActionController::Base.use_accept_header = old
   end
 
   def test_content_type
-    @request.env[&quot;CONTENT_TYPE&quot;] = &quot;text/html&quot;
-    assert_equal Mime::HTML, @request.content_type
+    request = stub_request 'CONTENT_TYPE' =&gt; 'text/html'
+    assert_equal Mime::HTML, request.content_type
   end
 
-  def test_format_assignment_should_set_format
-    @request.instance_eval { self.format = :txt }
-    assert !@request.format.xml?
-    @request.instance_eval { self.format = :xml }
-    assert @request.format.xml?
+  def test_can_override_format_with_parameter
+    request = stub_request
+    request.expects(:parameters).at_least_once.returns({ :format =&gt; :txt })
+    assert !request.format.xml?
+
+    request = stub_request
+    request.expects(:parameters).at_least_once.returns({ :format =&gt; :xml })
+    assert request.format.xml?
   end
 
   def test_content_no_type
-    assert_equal nil, @request.content_type
+    request = stub_request
+    assert_equal nil, request.content_type
   end
 
   def test_content_type_xml
-    @request.env[&quot;CONTENT_TYPE&quot;] = &quot;application/xml&quot;
-    assert_equal Mime::XML, @request.content_type
+    request = stub_request 'CONTENT_TYPE' =&gt; 'application/xml'
+    assert_equal Mime::XML, request.content_type
   end
 
   def test_content_type_with_charset
-    @request.env[&quot;CONTENT_TYPE&quot;] = &quot;application/xml; charset=UTF-8&quot;
-    assert_equal Mime::XML, @request.content_type
+    request = stub_request 'CONTENT_TYPE' =&gt; 'application/xml; charset=UTF-8'
+    assert_equal Mime::XML, request.content_type
   end
 
   def test_user_agent
-    assert_not_nil @request.user_agent
+    request = stub_request 'HTTP_USER_AGENT' =&gt; 'TestAgent'
+    assert_equal 'TestAgent', request.user_agent
   end
 
   def test_parameters
-    @request.stubs(:request_parameters).returns({ &quot;foo&quot; =&gt; 1 })
-    @request.stubs(:query_parameters).returns({ &quot;bar&quot; =&gt; 2 })
+    request = stub_request
+    request.stubs(:request_parameters).returns({ &quot;foo&quot; =&gt; 1 })
+    request.stubs(:query_parameters).returns({ &quot;bar&quot; =&gt; 2 })
 
-    assert_equal({&quot;foo&quot; =&gt; 1, &quot;bar&quot; =&gt; 2}, @request.parameters)
-    assert_equal({&quot;foo&quot; =&gt; 1}, @request.request_parameters)
-    assert_equal({&quot;bar&quot; =&gt; 2}, @request.query_parameters)
+    assert_equal({&quot;foo&quot; =&gt; 1, &quot;bar&quot; =&gt; 2}, request.parameters)
+    assert_equal({&quot;foo&quot; =&gt; 1}, request.request_parameters)
+    assert_equal({&quot;bar&quot; =&gt; 2}, request.query_parameters)
+  end
+
+protected
+
+  def stub_request(env={})
+    ActionController::Request.new(env)
   end
 
-  protected
-    def request_method=(method)
-      @request.env['REQUEST_METHOD'] = method.to_s.upcase
-      @request.request_method = nil # Reset the ivar cache
-    end
 end</diff>
      <filename>vendor/rails/actionpack/test/controller/request_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -120,6 +120,14 @@ class ResourcesTest &lt; ActionController::TestCase
     end
   end
 
+  def test_irregular_id_requirements_should_get_passed_to_member_actions
+    expected_options = {:controller =&gt; 'messages', :action =&gt; 'custom', :id =&gt; '1.1.1'}
+
+    with_restful_routing(:messages, :member =&gt; {:custom =&gt; :get}, :requirements =&gt; {:id =&gt; /[0-9]\.[0-9]\.[0-9]/}) do
+      assert_recognizes(expected_options, :path =&gt; 'messages/1.1.1/custom', :method =&gt; :get)
+    end
+  end
+
   def test_with_path_prefix
     with_restful_routing :messages, :path_prefix =&gt; '/thread/:thread_id' do
       assert_simply_restful_for :messages, :path_prefix =&gt; 'thread/5/', :options =&gt; { :thread_id =&gt; '5' }</diff>
      <filename>vendor/rails/actionpack/test/controller/resources_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -193,38 +193,6 @@ class CookieStoreTest &lt; ActionController::IntegrationTest
     end
   end
 
-  def test_session_store_with_expire_after
-    app = ActionController::Session::CookieStore.new(DispatcherApp, :key =&gt; SessionKey, :secret =&gt; SessionSecret, :expire_after =&gt; 5.hours)
-    @integration_session = open_session(app)
-
-    with_test_route_set do
-      # First request accesses the session
-      time = Time.local(2008, 4, 24)
-      Time.stubs(:now).returns(time)
-      expected_expiry = (time + 5.hours).gmtime.strftime(&quot;%a, %d-%b-%Y %H:%M:%S GMT&quot;)
-
-      cookies[SessionKey] = SignedBar
-
-      get '/set_session_value'
-      assert_response :success
-
-      cookie_body = response.body
-      assert_equal &quot;_myapp_session=#{cookie_body}; path=/; expires=#{expected_expiry}; HttpOnly&quot;,
-        headers['Set-Cookie']
-
-      # Second request does not access the session
-      time = Time.local(2008, 4, 25)
-      Time.stubs(:now).returns(time)
-      expected_expiry = (time + 5.hours).gmtime.strftime(&quot;%a, %d-%b-%Y %H:%M:%S GMT&quot;)
-
-      get '/no_session_access'
-      assert_response :success
-
-      assert_equal &quot;_myapp_session=#{cookie_body}; path=/; expires=#{expected_expiry}; HttpOnly&quot;,
-        headers['Set-Cookie']
-    end
-  end
-
   private
     def with_test_route_set
       with_routing do |set|
@@ -236,4 +204,13 @@ class CookieStoreTest &lt; ActionController::IntegrationTest
         yield
       end
     end
+
+    def unmarshal_session(cookie_string)
+      session = Rack::Utils.parse_query(cookie_string, ';,').inject({}) {|h,(k,v)|
+        h[k] = Array === v ? v.first : v
+        h
+      }[SessionKey]
+      verifier = ActiveSupport::MessageVerifier.new(SessionSecret, 'SHA1')
+      verifier.verify(session)
+    end
 end</diff>
      <filename>vendor/rails/actionpack/test/controller/session/cookie_store_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -515,6 +515,14 @@ XML
     assert_nil @request.instance_variable_get(&quot;@request_method&quot;)
   end
 
+  def test_params_reset_after_post_request
+    post :no_op, :foo =&gt; &quot;bar&quot;
+    assert_equal &quot;bar&quot;, @request.params[:foo]
+    @request.recycle!
+    post :no_op
+    assert @request.params[:foo].blank?
+  end
+
   %w(controller response request).each do |variable|
     %w(get post put delete head process).each do |method|
       define_method(&quot;test_#{variable}_missing_for_#{method}_raises_error&quot;) do</diff>
      <filename>vendor/rails/actionpack/test/controller/test_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -80,6 +80,14 @@ class FormOptionsHelperTest &lt; ActionView::TestCase
     )
   end
 
+  def test_string_options_for_select
+    options = &quot;&lt;option value=\&quot;Denmark\&quot;&gt;Denmark&lt;/option&gt;&lt;option value=\&quot;USA\&quot;&gt;USA&lt;/option&gt;&lt;option value=\&quot;Sweden\&quot;&gt;Sweden&lt;/option&gt;&quot;
+    assert_dom_equal(
+      options,
+      options_for_select(options)
+    )
+  end
+
   def test_array_options_for_select
     assert_dom_equal(
       &quot;&lt;option value=\&quot;&amp;lt;Denmark&amp;gt;\&quot;&gt;&amp;lt;Denmark&amp;gt;&lt;/option&gt;\n&lt;option value=\&quot;USA\&quot;&gt;USA&lt;/option&gt;\n&lt;option value=\&quot;Sweden\&quot;&gt;Sweden&lt;/option&gt;&quot;,
@@ -324,6 +332,20 @@ class FormOptionsHelperTest &lt; ActionView::TestCase
     )
   end
 
+  def test_select_under_fields_for_with_string_and_given_prompt
+    @post = Post.new
+    options = &quot;&lt;option value=\&quot;abe\&quot;&gt;abe&lt;/option&gt;&lt;option value=\&quot;mus\&quot;&gt;mus&lt;/option&gt;&lt;option value=\&quot;hest\&quot;&gt;hest&lt;/option&gt;&quot;
+
+    fields_for :post, @post do |f|
+      concat f.select(:category, options, :prompt =&gt; 'The prompt')
+    end
+
+    assert_dom_equal(
+      &quot;&lt;select id=\&quot;post_category\&quot; name=\&quot;post[category]\&quot;&gt;&lt;option value=\&quot;\&quot;&gt;The prompt&lt;/option&gt;\n#{options}&lt;/select&gt;&quot;,
+      output_buffer
+    )
+  end
+
   def test_select_with_blank
     @post = Post.new
     @post.category = &quot;&lt;mus&gt;&quot;</diff>
      <filename>vendor/rails/actionpack/test/template/form_options_helper_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -327,28 +327,28 @@ class JavaScriptGeneratorTest &lt; PrototypeHelperBaseTest
   def test_remove
     assert_equal 'Element.remove(&quot;foo&quot;);',
       @generator.remove('foo')
-    assert_equal '[&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;].each(Element.remove);',
+    assert_equal '[&quot;foo&quot;,&quot;bar&quot;,&quot;baz&quot;].each(Element.remove);',
       @generator.remove('foo', 'bar', 'baz')
   end
 
   def test_show
     assert_equal 'Element.show(&quot;foo&quot;);',
       @generator.show('foo')
-    assert_equal '[&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;].each(Element.show);',
+    assert_equal '[&quot;foo&quot;,&quot;bar&quot;,&quot;baz&quot;].each(Element.show);',
       @generator.show('foo', 'bar', 'baz')
   end
 
   def test_hide
     assert_equal 'Element.hide(&quot;foo&quot;);',
       @generator.hide('foo')
-    assert_equal '[&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;].each(Element.hide);',
+    assert_equal '[&quot;foo&quot;,&quot;bar&quot;,&quot;baz&quot;].each(Element.hide);',
       @generator.hide('foo', 'bar', 'baz')
   end
 
   def test_toggle
     assert_equal 'Element.toggle(&quot;foo&quot;);',
       @generator.toggle('foo')
-    assert_equal '[&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;].each(Element.toggle);',
+    assert_equal '[&quot;foo&quot;,&quot;bar&quot;,&quot;baz&quot;].each(Element.toggle);',
       @generator.toggle('foo', 'bar', 'baz')
   end
 
@@ -385,7 +385,7 @@ class JavaScriptGeneratorTest &lt; PrototypeHelperBaseTest
     assert_equal &lt;&lt;-EOS.chomp, @generator.to_s
 Element.insert(&quot;element&quot;, { top: &quot;\\u003Cp\\u003EThis is a test\\u003C/p\\u003E&quot; });
 Element.insert(&quot;element&quot;, { bottom: &quot;\\u003Cp\\u003EThis is a test\\u003C/p\\u003E&quot; });
-[&quot;foo&quot;, &quot;bar&quot;].each(Element.remove);
+[&quot;foo&quot;,&quot;bar&quot;].each(Element.remove);
 Element.update(&quot;baz&quot;, &quot;\\u003Cp\\u003EThis is a test\\u003C/p\\u003E&quot;);
     EOS
   end
@@ -554,8 +554,8 @@ return (value.className == &quot;welcome&quot;);
     end
 
     assert_equal &lt;&lt;-EOS.strip, @generator.to_s
-var a = [1, 2, 3].zip([4, 5, 6], [7, 8, 9]);
-var b = [1, 2, 3].zip([4, 5, 6], [7, 8, 9], function(array) {
+var a = [1, 2, 3].zip([4,5,6], [7,8,9]);
+var b = [1, 2, 3].zip([4,5,6], [7,8,9], function(array) {
 return array.reverse();
 });
     EOS
@@ -606,7 +606,7 @@ return value.reverse();
 
   def test_literal
     literal = @generator.literal(&quot;function() {}&quot;)
-    assert_equal &quot;function() {}&quot;, literal.to_json
+    assert_equal &quot;function() {}&quot;, ActiveSupport::JSON.encode(literal)
     assert_equal &quot;&quot;, @generator.to_s
   end
 </diff>
      <filename>vendor/rails/actionpack/test/template/prototype_helper_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,10 @@
+*2.3.3 (pending)*
+
+* Added :touch option to belongs_to associations that will touch the parent record when the current record is saved or destroyed [DHH]
+
+* Added ActiveRecord::Base#touch to update the updated_at/on attributes (or another specified timestamp) with the current time [DHH]
+
+
 *2.3.2 [Final] (March 15, 2009)*
 
 * Added ActiveRecord::Base.find_each and ActiveRecord::Base.find_in_batches for batch processing [DHH/Jamis Buck]</diff>
      <filename>vendor/rails/activerecord/CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -981,6 +981,9 @@ module ActiveRecord
       #   If false, don't validate the associated objects when saving the parent object. +false+ by default.
       # [:autosave]
       #   If true, always save the associated object or destroy it if marked for destruction, when saving the parent object. Off by default.
+      # [:touch]
+      #   If true, the associated object will be touched (the updated_at/on attributes set to now) when this record is either saved or
+      #   destroyed. If you specify a symbol, that attribute will be updated with the current time instead of the updated_at/on attribute.
       #
       # Option examples:
       #   belongs_to :firm, :foreign_key =&gt; &quot;client_of&quot;
@@ -990,6 +993,8 @@ module ActiveRecord
       #   belongs_to :attachable, :polymorphic =&gt; true
       #   belongs_to :project, :readonly =&gt; true
       #   belongs_to :post, :counter_cache =&gt; true
+      #   belongs_to :company, :touch =&gt; true
+      #   belongs_to :company, :touch =&gt; :employees_last_updated_at
       def belongs_to(association_id, options = {})
         reflection = create_belongs_to_reflection(association_id, options)
 
@@ -1001,28 +1006,8 @@ module ActiveRecord
           association_constructor_method(:create, reflection, BelongsToAssociation)
         end
 
-        # Create the callbacks to update counter cache
-        if options[:counter_cache]
-          cache_column = reflection.counter_cache_column
-
-          method_name = &quot;belongs_to_counter_cache_after_create_for_#{reflection.name}&quot;.to_sym
-          define_method(method_name) do
-            association = send(reflection.name)
-            association.class.increment_counter(cache_column, send(reflection.primary_key_name)) unless association.nil?
-          end
-          after_create method_name
-
-          method_name = &quot;belongs_to_counter_cache_before_destroy_for_#{reflection.name}&quot;.to_sym
-          define_method(method_name) do
-            association = send(reflection.name)
-            association.class.decrement_counter(cache_column, send(reflection.primary_key_name)) unless association.nil?
-          end
-          before_destroy method_name
-
-          module_eval(
-            &quot;#{reflection.class_name}.send(:attr_readonly,\&quot;#{cache_column}\&quot;.intern) if defined?(#{reflection.class_name}) &amp;&amp; #{reflection.class_name}.respond_to?(:attr_readonly)&quot;
-          )
-        end
+        add_counter_cache_callbacks(reflection)          if options[:counter_cache]
+        add_touch_callbacks(reflection, options[:touch]) if options[:touch]
 
         configure_dependency_for_belongs_to(reflection)
       end
@@ -1329,6 +1314,43 @@ module ActiveRecord
           end
         end
 
+        def add_counter_cache_callbacks(reflection)
+          cache_column = reflection.counter_cache_column
+
+          method_name = &quot;belongs_to_counter_cache_after_create_for_#{reflection.name}&quot;.to_sym
+          define_method(method_name) do
+            association = send(reflection.name)
+            association.class.increment_counter(cache_column, send(reflection.primary_key_name)) unless association.nil?
+          end
+          after_create(method_name)
+
+          method_name = &quot;belongs_to_counter_cache_before_destroy_for_#{reflection.name}&quot;.to_sym
+          define_method(method_name) do
+            association = send(reflection.name)
+            association.class.decrement_counter(cache_column, send(reflection.primary_key_name)) unless association.nil?
+          end
+          before_destroy(method_name)
+
+          module_eval(
+            &quot;#{reflection.class_name}.send(:attr_readonly,\&quot;#{cache_column}\&quot;.intern) if defined?(#{reflection.class_name}) &amp;&amp; #{reflection.class_name}.respond_to?(:attr_readonly)&quot;
+          )
+        end
+        
+        def add_touch_callbacks(reflection, touch_attribute)
+          method_name = &quot;belongs_to_touch_after_save_or_destroy_for_#{reflection.name}&quot;.to_sym
+          define_method(method_name) do
+            association = send(reflection.name)
+            
+            if touch_attribute == true
+              association.touch unless association.nil?
+            else
+              association.touch(touch_attribute) unless association.nil?
+            end
+          end
+          after_save(method_name)
+          after_destroy(method_name)
+        end
+
         def find_with_associations(options = {})
           catch :invalid_query do
             join_dependency = JoinDependency.new(self, merge_includes(scope(:find, :include), options[:include]), options[:joins])
@@ -1353,7 +1375,7 @@ module ActiveRecord
             dependent_conditions = []
             dependent_conditions &lt;&lt; &quot;#{reflection.primary_key_name} = \#{record.quoted_id}&quot;
             dependent_conditions &lt;&lt; &quot;#{reflection.options[:as]}_type = '#{base_class.name}'&quot; if reflection.options[:as]
-            dependent_conditions &lt;&lt; sanitize_sql(reflection.options[:conditions]) if reflection.options[:conditions]
+            dependent_conditions &lt;&lt; sanitize_sql(reflection.options[:conditions], reflection.quoted_table_name) if reflection.options[:conditions]
             dependent_conditions &lt;&lt; extra_conditions if extra_conditions
             dependent_conditions = dependent_conditions.collect {|where| &quot;(#{where})&quot; }.join(&quot; AND &quot;)
             dependent_conditions = dependent_conditions.gsub('@', '\@')
@@ -1499,7 +1521,7 @@ module ActiveRecord
         @@valid_keys_for_belongs_to_association = [
           :class_name, :foreign_key, :foreign_type, :remote, :select, :conditions,
           :include, :dependent, :counter_cache, :extend, :polymorphic, :readonly,
-          :validate
+          :validate, :touch
         ]
 
         def create_belongs_to_reflection(association_id, options)
@@ -1643,17 +1665,29 @@ module ActiveRecord
           string.scan(/([\.a-zA-Z_]+).?\./).flatten
         end
 
+        def tables_in_hash(hash)
+          return [] if hash.blank?
+          tables = hash.map do |key, value|
+            if value.is_a?(Hash)
+              key.to_s
+            else
+              tables_in_string(key) if key.is_a?(String)
+            end
+          end
+          tables.flatten.compact
+        end
+
         def conditions_tables(options)
           # look in both sets of conditions
           conditions = [scope(:find, :conditions), options[:conditions]].inject([]) do |all, cond|
             case cond
               when nil   then all
-              when Array then all &lt;&lt; cond.first
-              when Hash  then all &lt;&lt; cond.keys
-              else            all &lt;&lt; cond
+              when Array then all &lt;&lt; tables_in_string(cond.first)
+              when Hash  then all &lt;&lt; tables_in_hash(cond)
+              else            all &lt;&lt; tables_in_string(cond)
             end
           end
-          tables_in_string(conditions.join(' '))
+          conditions.flatten
         end
 
         def order_tables(options)
@@ -2101,7 +2135,7 @@ module ActiveRecord
                 klass.send(:type_condition, aliased_table_name)] unless klass.descends_from_active_record?
 
               [through_reflection, reflection].each do |ref|
-                join &lt;&lt; &quot;AND #{interpolate_sql(sanitize_sql(ref.options[:conditions]))} &quot; if ref &amp;&amp; ref.options[:conditions]
+                join &lt;&lt; &quot;AND #{interpolate_sql(sanitize_sql(ref.options[:conditions], aliased_table_name))} &quot; if ref &amp;&amp; ref.options[:conditions]
               end
 
               join</diff>
      <filename>vendor/rails/activerecord/lib/active_record/associations.rb</filename>
    </modified>
    <modified>
      <diff>@@ -143,6 +143,8 @@ module ActiveRecord
       end
 
       # Remove all records from this association
+      #
+      # See delete for more info.
       def delete_all
         load_target
         delete(@target)
@@ -200,11 +202,11 @@ module ActiveRecord
         end
       end
 
-      # Destroy +records+ and remove from this association calling +before_remove+
-      # and +after_remove+ callbacks.
+      # Destroy +records+ and remove them from this association calling
+      # +before_remove+ and +after_remove+ callbacks.
       #
-      # Note this method will always remove records from database ignoring the
-      # +:dependent+ option.
+      # Note that this method will _always_ remove records from the database
+      # ignoring the +:dependent+ option.
       def destroy(*records)
         remove_records(records) do |records, old_records|
           old_records.each { |record| record.destroy }
@@ -226,7 +228,9 @@ module ActiveRecord
         self
       end
 
-      # Destory all the records from this association
+      # Destory all the records from this association.
+      #
+      # See destroy for more info.
       def destroy_all
         load_target
         destroy(@target)</diff>
      <filename>vendor/rails/activerecord/lib/active_record/associations/association_collection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -169,8 +169,8 @@ module ActiveRecord
         end
 
         # Forwards the call to the reflection class.
-        def sanitize_sql(sql)
-          @reflection.klass.send(:sanitize_sql, sql)
+        def sanitize_sql(sql, table_name = @reflection.klass.quoted_table_name)
+          @reflection.klass.send(:sanitize_sql, sql, table_name)
         end
 
         # Assigns the ID of the owner to the corresponding foreign key in +record+.</diff>
      <filename>vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,6 +22,13 @@ module ActiveRecord
         end
       end
 
+      def destroy(*records)
+        transaction do
+          delete_records(flatten_deeper(records))
+          super
+        end
+      end
+
       # Returns the size of the collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and
       # calling collection.size if it has. If it's more likely than not that the collection does have a size larger than zero,
       # and you need to fetch that collection afterwards, it'll take one fewer SELECT query if you use #length.</diff>
      <filename>vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,31 +1,31 @@
 module ActiveRecord
   module Associations
     class HasOneThroughAssociation &lt; HasManyThroughAssociation
-      
+
       def create_through_record(new_value) #nodoc:
         klass = @reflection.through_reflection.klass
 
         current_object = @owner.send(@reflection.through_reflection.name)
-        
+
         if current_object
-          current_object.update_attributes(construct_join_attributes(new_value))
+          new_value ? current_object.update_attributes(construct_join_attributes(new_value)) : current_object.destroy
         else
-          @owner.send(@reflection.through_reflection.name,  klass.send(:create, construct_join_attributes(new_value)))
+          @owner.send(@reflection.through_reflection.name,  klass.send(:create, construct_join_attributes(new_value))) if new_value
         end
       end
-      
+
     private
       def find(*args)
         super(args.merge(:limit =&gt; 1))
       end
-    
+
       def find_target
         super.first
       end
 
       def reset_target!
         @target = nil
-      end        
-    end        
+      end
+    end
   end
 end</diff>
      <filename>vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb</filename>
    </modified>
    <modified>
      <diff>@@ -311,11 +311,13 @@ module ActiveRecord
     # ActiveRecord::Base after the AutosaveAssociation module, which it does by default.
     def save_has_one_association(reflection)
       if (association = association_instance_get(reflection.name)) &amp;&amp; !association.target.nil?
-        if reflection.options[:autosave] &amp;&amp; association.marked_for_destruction?
+        autosave = reflection.options[:autosave]
+
+        if autosave &amp;&amp; association.marked_for_destruction?
           association.destroy
-        elsif new_record? || association.new_record? || association[reflection.primary_key_name] != id || reflection.options[:autosave]
+        elsif new_record? || association.new_record? || association[reflection.primary_key_name] != id || autosave
           association[reflection.primary_key_name] = id
-          association.save(false)
+          association.save(!autosave)
         end
       end
     end
@@ -330,10 +332,12 @@ module ActiveRecord
     # ActiveRecord::Base after the AutosaveAssociation module, which it does by default.
     def save_belongs_to_association(reflection)
       if association = association_instance_get(reflection.name)
-        if reflection.options[:autosave] &amp;&amp; association.marked_for_destruction?
+        autosave = reflection.options[:autosave]
+
+        if autosave &amp;&amp; association.marked_for_destruction?
           association.destroy
         else
-          association.save(false) if association.new_record? || reflection.options[:autosave]
+          association.save(!autosave) if association.new_record? || autosave
 
           if association.updated?
             self[reflection.primary_key_name] = association.id</diff>
      <filename>vendor/rails/activerecord/lib/active_record/autosave_association.rb</filename>
    </modified>
    <modified>
      <diff>@@ -687,14 +687,9 @@ module ActiveRecord #:nodoc:
       #   Person.exists?(['name LIKE ?', &quot;%#{query}%&quot;])
       #   Person.exists?
       def exists?(id_or_conditions = {})
-        connection.select_all(
-          construct_finder_sql(
-            :select     =&gt; &quot;#{quoted_table_name}.#{primary_key}&quot;,
-            :conditions =&gt; expand_id_conditions(id_or_conditions),
-            :limit      =&gt; 1
-          ),
-          &quot;#{name} Exists&quot;
-        ).size &gt; 0
+        find_initial(
+          :select =&gt; &quot;#{quoted_table_name}.#{primary_key}&quot;,
+          :conditions =&gt; expand_id_conditions(id_or_conditions)) ? true : false
       end
 
       # Creates an object (or multiple objects) and saves it to the database, if validations pass.
@@ -736,12 +731,12 @@ module ActiveRecord #:nodoc:
       # ==== Parameters
       #
       # * +id+ - This should be the id or an array of ids to be updated.
-      # * +attributes+ - This should be a Hash of attributes to be set on the object, or an array of Hashes.
+      # * +attributes+ - This should be a hash of attributes to be set on the object, or an array of hashes.
       #
       # ==== Examples
       #
       #   # Updating one record:
-      #   Person.update(15, { :user_name =&gt; 'Samuel', :group =&gt; 'expert' })
+      #   Person.update(15, :user_name =&gt; 'Samuel', :group =&gt; 'expert')
       #
       #   # Updating multiple records:
       #   people = { 1 =&gt; { &quot;first_name&quot; =&gt; &quot;David&quot; }, 2 =&gt; { &quot;first_name&quot; =&gt; &quot;Jeremy&quot; } }
@@ -2168,7 +2163,7 @@ module ActiveRecord #:nodoc:
         #     default_scope :order =&gt; 'last_name, first_name'
         #   end
         def default_scope(options = {})
-          self.default_scoping &lt;&lt; { :find =&gt; options, :create =&gt; (options.is_a?(Hash) &amp;&amp; options.has_key?(:conditions)) ? options[:conditions] : {} }
+          self.default_scoping &lt;&lt; { :find =&gt; options, :create =&gt; options[:conditions].is_a?(Hash) ? options[:conditions] : {} }
         end
 
         # Test whether the given method and optional key are scoped.
@@ -2228,12 +2223,12 @@ module ActiveRecord #:nodoc:
         #   [&quot;name='%s' and group_id='%s'&quot;, &quot;foo'bar&quot;, 4]  returns  &quot;name='foo''bar' and group_id='4'&quot;
         #   { :name =&gt; &quot;foo'bar&quot;, :group_id =&gt; 4 }  returns &quot;name='foo''bar' and group_id='4'&quot;
         #   &quot;name='foo''bar' and group_id='4'&quot; returns &quot;name='foo''bar' and group_id='4'&quot;
-        def sanitize_sql_for_conditions(condition)
+        def sanitize_sql_for_conditions(condition, table_name = quoted_table_name)
           return nil if condition.blank?
 
           case condition
             when Array; sanitize_sql_array(condition)
-            when Hash;  sanitize_sql_hash_for_conditions(condition)
+            when Hash;  sanitize_sql_hash_for_conditions(condition, table_name)
             else        condition
           end
         end</diff>
      <filename>vendor/rails/activerecord/lib/active_record/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,10 +4,12 @@ module ActiveRecord
       base.extend(ClassMethods)
     end
 
-    # When processing large numbers of records, it's often a good idea to do so in batches to prevent memory ballooning.
+    # When processing large numbers of records, it's often a good idea to do
+    # so in batches to prevent memory ballooning.
     module ClassMethods
-      # Yields each record that was found by the find +options+. The find is performed by find_in_batches
-      # with a batch size of 1000 (or as specified by the +batch_size+ option).
+      # Yields each record that was found by the find +options+. The find is
+      # performed by find_in_batches with a batch size of 1000 (or as
+      # specified by the &lt;tt&gt;:batch_size&lt;/tt&gt; option).
       #
       # Example:
       #
@@ -15,9 +17,10 @@ module ActiveRecord
       #     person.party_all_night!
       #   end
       #
-      # Note: This method is only intended to use for batch processing of large amounts of records that wouldn't fit in
-      # memory all at once. If you just need to loop over less than 1000 records, it's probably better just to use the
-      # regular find methods.
+      # Note: This method is only intended to use for batch processing of
+      # large amounts of records that wouldn't fit in memory all at once. If
+      # you just need to loop over less than 1000 records, it's probably
+      # better just to use the regular find methods.
       def find_each(options = {})
         find_in_batches(options) do |records|
           records.each { |record| yield record }
@@ -26,17 +29,22 @@ module ActiveRecord
         self
       end
 
-      # Yields each batch of records that was found by the find +options+ as an array. The size of each batch is
-      # set by the +batch_size+ option; the default is 1000.
+      # Yields each batch of records that was found by the find +options+ as
+      # an array. The size of each batch is set by the &lt;tt&gt;:batch_size&lt;/tt&gt;
+      # option; the default is 1000.
       #
-      # You can control the starting point for the batch processing by supplying the +start+ option. This is especially
-      # useful if you want multiple workers dealing with the same processing queue. You can make worker 1 handle all the
-      # records between id 0 and 10,000 and worker 2 handle from 10,000 and beyond (by setting the +start+ option on that
-      # worker).
+      # You can control the starting point for the batch processing by
+      # supplying the &lt;tt&gt;:start&lt;/tt&gt; option. This is especially useful if you
+      # want multiple workers dealing with the same processing queue. You can
+      # make worker 1 handle all the records between id 0 and 10,000 and
+      # worker 2 handle from 10,000 and beyond (by setting the &lt;tt&gt;:start&lt;/tt&gt;
+      # option on that worker).
       #
-      # It's not possible to set the order. That is automatically set to ascending on the primary key (&quot;id ASC&quot;) 
-      # to make the batch ordering work. This also mean that this method only works with integer-based primary keys.
-      # You can't set the limit either, that's used to control the the batch sizes.
+      # It's not possible to set the order. That is automatically set to
+      # ascending on the primary key (&quot;id ASC&quot;) to make the batch ordering
+      # work. This also mean that this method only works with integer-based
+      # primary keys. You can't set the limit either, that's used to control
+      # the the batch sizes.
       #
       # Example:
       #</diff>
      <filename>vendor/rails/activerecord/lib/active_record/batches.rb</filename>
    </modified>
    <modified>
      <diff>@@ -392,9 +392,28 @@ module ActiveRecord
         quote_string(s)
       end
 
+      # Checks the following cases:
+      #
+      # - table_name
+      # - &quot;table.name&quot;
+      # - schema_name.table_name
+      # - schema_name.&quot;table.name&quot;
+      # - &quot;schema.name&quot;.table_name
+      # - &quot;schema.name&quot;.&quot;table.name&quot;
+      def quote_table_name(name)
+        schema, name_part = extract_pg_identifier_from_name(name.to_s)
+
+        unless name_part
+          quote_column_name(schema)
+        else
+          table_name, name_part = extract_pg_identifier_from_name(name_part)
+          &quot;#{quote_column_name(schema)}.#{quote_column_name(table_name)}&quot;
+        end
+      end
+
       # Quotes column names for use in SQL queries.
       def quote_column_name(name) #:nodoc:
-        %(&quot;#{name}&quot;)
+        PGconn.quote_ident(name.to_s)
       end
 
       # Quote date/time values for use in SQL input. Includes microseconds
@@ -621,33 +640,36 @@ module ActiveRecord
       def indexes(table_name, name = nil)
          schemas = schema_search_path.split(/,/).map { |p| quote(p) }.join(',')
          result = query(&lt;&lt;-SQL, name)
-           SELECT distinct i.relname, d.indisunique, a.attname
-             FROM pg_class t, pg_class i, pg_index d, pg_attribute a
+           SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
+             FROM pg_class t, pg_class i, pg_index d
            WHERE i.relkind = 'i'
              AND d.indexrelid = i.oid
              AND d.indisprimary = 'f'
              AND t.oid = d.indrelid
              AND t.relname = '#{table_name}'
              AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN (#{schemas}) )
-             AND a.attrelid = t.oid
-             AND ( d.indkey[0]=a.attnum OR d.indkey[1]=a.attnum
-                OR d.indkey[2]=a.attnum OR d.indkey[3]=a.attnum
-                OR d.indkey[4]=a.attnum OR d.indkey[5]=a.attnum
-                OR d.indkey[6]=a.attnum OR d.indkey[7]=a.attnum
-                OR d.indkey[8]=a.attnum OR d.indkey[9]=a.attnum )
           ORDER BY i.relname
         SQL
 
-        current_index = nil
+
         indexes = []
 
-        result.each do |row|
-          if current_index != row[0]
-            indexes &lt;&lt; IndexDefinition.new(table_name, row[0], row[1] == &quot;t&quot;, [])
-            current_index = row[0]
-          end
+        indexes = result.map do |row|
+          index_name = row[0]
+          unique = row[1] == 't'
+          indkey = row[2].split(&quot; &quot;)
+          oid = row[3]
+
+          columns = query(&lt;&lt;-SQL, &quot;Columns for index #{row[0]} on #{table_name}&quot;).inject({}) {|attlist, r| attlist[r[1]] = r[0]; attlist}
+          SELECT a.attname, a.attnum
+          FROM pg_attribute a
+          WHERE a.attrelid = #{oid}
+          AND a.attnum IN (#{indkey.join(&quot;,&quot;)})
+          SQL
+
+          column_names = indkey.map {|attnum| columns[attnum] }
+          IndexDefinition.new(table_name, index_name, unique, column_names)
 
-          indexes.last.columns &lt;&lt; row[2]
         end
 
         indexes
@@ -745,7 +767,7 @@ module ActiveRecord
             AND attr.attrelid     = cons.conrelid
             AND attr.attnum       = cons.conkey[1]
             AND cons.contype      = 'p'
-            AND dep.refobjid      = '#{table}'::regclass
+            AND dep.refobjid      = '#{quote_table_name(table)}'::regclass
         end_sql
 
         if result.nil? or result.empty?
@@ -764,7 +786,7 @@ module ActiveRecord
             JOIN pg_attribute   attr ON (t.oid = attrelid)
             JOIN pg_attrdef     def  ON (adrelid = attrelid AND adnum = attnum)
             JOIN pg_constraint  cons ON (conrelid = adrelid AND adnum = conkey[1])
-            WHERE t.oid = '#{table}'::regclass
+            WHERE t.oid = '#{quote_table_name(table)}'::regclass
               AND cons.contype = 'p'
               AND def.adsrc ~* 'nextval'
           end_sql
@@ -839,7 +861,7 @@ module ActiveRecord
 
       # Drops an index from a table.
       def remove_index(table_name, options = {})
-        execute &quot;DROP INDEX #{index_name(table_name, options)}&quot;
+        execute &quot;DROP INDEX #{quote_table_name(index_name(table_name, options))}&quot;
       end
 
       # Maps logical Rails types to PostgreSQL-specific data types.
@@ -1040,11 +1062,21 @@ module ActiveRecord
             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
               FROM pg_attribute a LEFT JOIN pg_attrdef d
                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
-             WHERE a.attrelid = '#{table_name}'::regclass
+             WHERE a.attrelid = '#{quote_table_name(table_name)}'::regclass
                AND a.attnum &gt; 0 AND NOT a.attisdropped
              ORDER BY a.attnum
           end_sql
         end
+
+        def extract_pg_identifier_from_name(name)
+          match_data = name[0,1] == '&quot;' ? name.match(/\&quot;([^\&quot;]+)\&quot;/) : name.match(/([^\.]+)/)
+
+          if match_data
+            rest = name[match_data[0].length..-1]
+            rest = rest[1..-1] if rest[0,1] == &quot;.&quot;
+            [match_data[1], (rest.length &gt; 0 ? rest : nil)]
+          end
+        end
     end
   end
 end</diff>
      <filename>vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
 require 'erb'
 require 'yaml'
 require 'csv'
+require 'zlib'
 require 'active_support/dependencies'
 require 'active_support/test_case'
 
@@ -433,6 +434,7 @@ end
 # Any fixture labeled &quot;DEFAULTS&quot; is safely ignored.
 
 class Fixtures &lt; (RUBY_VERSION &lt; '1.9' ? YAML::Omap : Hash)
+  MAX_ID = 2 ** 31 - 1
   DEFAULT_FILTER_RE = /\.ya?ml$/
 
   @@all_cached_fixtures = {}
@@ -524,11 +526,10 @@ class Fixtures &lt; (RUBY_VERSION &lt; '1.9' ? YAML::Omap : Hash)
     cached_fixtures(connection, table_names)
   end
 
-  # Returns a consistent identifier for +label+. This will always
-  # be a positive integer, and will always be the same for a given
-  # label, assuming the same OS, platform, and version of Ruby.
+  # Returns a consistent, platform-independent identifier for +label+.
+  # Identifiers are positive integers less than 2^32.
   def self.identify(label)
-    label.to_s.hash.abs
+    Zlib.crc32(label.to_s) % MAX_ID
   end
 
   attr_reader :table_name, :name</diff>
      <filename>vendor/rails/activerecord/lib/active_record/fixtures.rb</filename>
    </modified>
    <modified>
      <diff>@@ -114,7 +114,7 @@ module ActiveRecord
         end
       end
 
-      delegate :scopes, :with_scope, :to =&gt; :proxy_scope
+      delegate :scopes, :with_scope, :scoped_methods, :to =&gt; :proxy_scope
 
       def initialize(proxy_scope, options, &amp;block)
         options ||= {}
@@ -178,7 +178,7 @@ module ActiveRecord
         else
           with_scope({:find =&gt; proxy_options, :create =&gt; proxy_options[:conditions].is_a?(Hash) ?  proxy_options[:conditions] : {}}, :reverse_merge) do
             method = :new if method == :build
-            if current_scoped_methods_when_defined
+            if current_scoped_methods_when_defined &amp;&amp; !scoped_methods.include?(current_scoped_methods_when_defined)
               with_scope current_scoped_methods_when_defined do
                 proxy_scope.send(method, *args, &amp;block)
               end</diff>
      <filename>vendor/rails/activerecord/lib/active_record/named_scope.rb</filename>
    </modified>
    <modified>
      <diff>@@ -72,13 +72,17 @@ module ActiveRecord #:nodoc:
     #                   {&quot;comments&quot;: [{&quot;body&quot;: &quot;Don't think too hard&quot;}],
     #                    &quot;title&quot;: &quot;So I was thinking&quot;}]}
     def to_json(options = {})
+      json = JsonSerializer.new(self, options).to_s
       if include_root_in_json
-        &quot;{#{self.class.json_class_name}: #{JsonSerializer.new(self, options).to_s}}&quot;
+        &quot;{#{self.class.json_class_name}:#{json}}&quot;
       else
-        JsonSerializer.new(self, options).to_s
+        json
       end
     end
 
+    # For compatibility with ActiveSupport::JSON.encode
+    alias rails_to_json to_json
+
     def from_json(json)
       self.attributes = ActiveSupport::JSON.decode(json)
       self
@@ -86,7 +90,7 @@ module ActiveRecord #:nodoc:
 
     class JsonSerializer &lt; ActiveRecord::Serialization::Serializer #:nodoc:
       def serialize
-        serializable_record.to_json
+        ActiveSupport::JSON.encode(serializable_record)
       end
     end
 </diff>
      <filename>vendor/rails/activerecord/lib/active_record/serializers/json_serializer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -295,7 +295,7 @@ module ActiveRecord
 
       def set_session(env, sid, session_data)
         Base.silence do
-          record = env[SESSION_RECORD_KEY] ||= find_session(sid)
+          record = get_session_model(env, sid)
           record.data = session_data
           return false unless record.save
 
@@ -309,6 +309,14 @@ module ActiveRecord
 
         return true
       end
+      
+      def get_session_model(env, sid)
+        if env[ENV_SESSION_OPTIONS_KEY][:id].nil?
+          env[SESSION_RECORD_KEY] = find_session(sid)
+        else
+          env[SESSION_RECORD_KEY] ||= find_session(sid)
+        end
+      end
 
       def find_session(id)
         @@session_class.find_by_session_id(id) ||</diff>
      <filename>vendor/rails/activerecord/lib/active_record/session_store.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,27 +15,57 @@ module ActiveRecord
       base.class_inheritable_accessor :record_timestamps, :instance_writer =&gt; false
       base.record_timestamps = true
     end
+    
+    # Saves the record with the updated_at/on attributes set to the current time.
+    # If the save fails because of validation errors, an ActiveRecord::RecordInvalid exception is raised.
+    # If an attribute name is passed, that attribute is used for the touch instead of the updated_at/on attributes.
+    #
+    # Examples:
+    #
+    #   product.touch               # updates updated_at
+    #   product.touch(:designed_at) # updates the designed_at attribute
+    def touch(attribute = nil)
+      current_time = current_time_from_proper_timezone
+
+      if attribute
+        write_attribute(attribute, current_time)
+      else
+        write_attribute('updated_at', current_time) if respond_to?(:updated_at)
+        write_attribute('updated_on', current_time) if respond_to?(:updated_on)
+      end
+
+      save!
+    end
+
 
     private
       def create_with_timestamps #:nodoc:
         if record_timestamps
-          t = self.class.default_timezone == :utc ? Time.now.utc : Time.now
-          write_attribute('created_at', t) if respond_to?(:created_at) &amp;&amp; created_at.nil?
-          write_attribute('created_on', t) if respond_to?(:created_on) &amp;&amp; created_on.nil?
+          current_time = current_time_from_proper_timezone
 
-          write_attribute('updated_at', t) if respond_to?(:updated_at) &amp;&amp; updated_at.nil?
-          write_attribute('updated_on', t) if respond_to?(:updated_on) &amp;&amp; updated_on.nil?
+          write_attribute('created_at', current_time) if respond_to?(:created_at) &amp;&amp; created_at.nil?
+          write_attribute('created_on', current_time) if respond_to?(:created_on) &amp;&amp; created_on.nil?
+
+          write_attribute('updated_at', current_time) if respond_to?(:updated_at) &amp;&amp; updated_at.nil?
+          write_attribute('updated_on', current_time) if respond_to?(:updated_on) &amp;&amp; updated_on.nil?
         end
+
         create_without_timestamps
       end
 
       def update_with_timestamps(*args) #:nodoc:
         if record_timestamps &amp;&amp; (!partial_updates? || changed?)
-          t = self.class.default_timezone == :utc ? Time.now.utc : Time.now
-          write_attribute('updated_at', t) if respond_to?(:updated_at)
-          write_attribute('updated_on', t) if respond_to?(:updated_on)
+          current_time = current_time_from_proper_timezone
+
+          write_attribute('updated_at', current_time) if respond_to?(:updated_at)
+          write_attribute('updated_on', current_time) if respond_to?(:updated_on)
         end
+
         update_without_timestamps(*args)
       end
+      
+      def current_time_from_proper_timezone
+        self.class.default_timezone == :utc ? Time.now.utc : Time.now
+      end
   end
-end
+end
\ No newline at end of file</diff>
      <filename>vendor/rails/activerecord/lib/active_record/timestamp.rb</filename>
    </modified>
    <modified>
      <diff>@@ -802,7 +802,7 @@ module ActiveRecord
       # Validates whether the value of the specified attribute is available in a particular enumerable object.
       #
       #   class Person &lt; ActiveRecord::Base
-      #     validates_inclusion_of :gender, :in =&gt; %w( m f ), :message =&gt; &quot;woah! what are you then!??!!&quot;
+      #     validates_inclusion_of :gender, :in =&gt; %w( m f )
       #     validates_inclusion_of :age, :in =&gt; 0..99
       #     validates_inclusion_of :format, :in =&gt; %w( jpg gif png ), :message =&gt; &quot;extension {{value}} is not included in the list&quot;
       #   end</diff>
      <filename>vendor/rails/activerecord/lib/active_record/validations.rb</filename>
    </modified>
    <modified>
      <diff>@@ -223,6 +223,18 @@ class EagerAssociationTest &lt; ActiveRecord::TestCase
     end
   end
 
+  def test_eager_association_loading_with_belongs_to_and_conditions_hash
+    comments = []
+    assert_nothing_raised do
+      comments = Comment.find(:all, :include =&gt; :post, :conditions =&gt; {:posts =&gt; {:id =&gt; 4}}, :limit =&gt; 3, :order =&gt; 'comments.id')
+    end
+    assert_equal 3, comments.length
+    assert_equal [5,6,7], comments.collect { |c| c.id }
+    assert_no_queries do
+      comments.first.post
+    end
+  end
+
   def test_eager_association_loading_with_belongs_to_and_conditions_string_with_quoted_table_name
     quoted_posts_id= Comment.connection.quote_table_name('posts') + '.' + Comment.connection.quote_column_name('id')
     assert_nothing_raised do</diff>
      <filename>vendor/rails/activerecord/test/cases/associations/eager_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -719,6 +719,12 @@ class HasManyAssociationsTest &lt; ActiveRecord::TestCase
     assert Client.find(:all, :conditions =&gt; &quot;firm_id=#{firm.id}&quot;).empty?
   end
 
+  def test_dependence_for_associations_with_hash_condition
+    david = authors(:david)
+    post = posts(:thinking).id
+    assert_difference('Post.count', -1) { assert david.destroy }
+  end
+
   def test_destroy_dependent_when_deleted_from_association
     firm = Firm.find(:first)
     assert_equal 2, firm.clients.size</diff>
      <filename>vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -93,7 +93,7 @@ class HasManyThroughAssociationsTest &lt; ActiveRecord::TestCase
   end
 
   def test_destroy_association
-    assert_difference &quot;Person.count&quot;, -1 do
+    assert_difference [&quot;Person.count&quot;, &quot;Reader.count&quot;], -1 do
       posts(:welcome).people.destroy(people(:michael))
     end
 
@@ -102,7 +102,7 @@ class HasManyThroughAssociationsTest &lt; ActiveRecord::TestCase
   end
 
   def test_destroy_all
-    assert_difference &quot;Person.count&quot;, -1 do
+    assert_difference [&quot;Person.count&quot;, &quot;Reader.count&quot;], -1 do
       posts(:welcome).people.destroy_all
     end
 
@@ -110,6 +110,12 @@ class HasManyThroughAssociationsTest &lt; ActiveRecord::TestCase
     assert posts(:welcome).people(true).empty?
   end
 
+  def test_should_raise_exception_for_destroying_mismatching_records
+    assert_no_difference [&quot;Person.count&quot;, &quot;Reader.count&quot;] do
+      assert_raise(ActiveRecord::AssociationTypeMismatch) { posts(:welcome).people.destroy(posts(:thinking)) }
+    end
+  end
+
   def test_replace_association
     assert_queries(4){posts(:welcome);people(:david);people(:michael); posts(:welcome).people(true)}
     </diff>
      <filename>vendor/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -43,7 +43,14 @@ class HasOneThroughAssociationsTest &lt; ActiveRecord::TestCase
       @member.reload      
     end
   end
-  
+
+  def test_set_record_to_nil_should_delete_association
+    @member.club = nil
+    @member.reload
+    assert_equal nil, @member.current_membership
+    assert_nil @member.club
+  end
+
   def test_has_one_through_polymorphic
     assert_equal clubs(:moustache_club), @member.sponsor_club
   end</diff>
      <filename>vendor/rails/activerecord/test/cases/associations/has_one_through_associations_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,6 +29,11 @@ class InnerJoinAssociationTest &lt; ActiveRecord::TestCase
     assert_match /INNER JOIN .?categories.? ON.*AND.*.?General.?.*TERMINATING_MARKER/, sql
   end
 
+  def test_construct_finder_sql_applies_aliases_tables_on_association_conditions
+    result = Author.find(:all, :joins =&gt; [:thinking_posts, :welcome_posts])
+    assert_equal authors(:david), result.first
+  end
+
   def test_construct_finder_sql_unpacks_nested_joins
     sql = Author.send(:construct_finder_sql, :joins =&gt; {:posts =&gt; [[:comments]]})
     assert_no_match /inner join.*inner join.*inner join/i, sql, &quot;only two join clauses should be present&quot;</diff>
      <filename>vendor/rails/activerecord/test/cases/associations/inner_join_association_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -38,6 +38,17 @@ class TestAutosaveAssociationsInGeneral &lt; ActiveRecord::TestCase
 end
 
 class TestDefaultAutosaveAssociationOnAHasOneAssociation &lt; ActiveRecord::TestCase
+  def test_should_save_parent_but_not_invalid_child
+    firm = Firm.new(:name =&gt; 'GlobalMegaCorp')
+    assert firm.valid?
+
+    firm.build_account_using_primary_key
+    assert !firm.build_account_using_primary_key.valid?
+
+    assert firm.save
+    assert firm.account_using_primary_key.new_record?
+  end
+
   def test_save_fails_for_invalid_has_one
     firm = Firm.find(:first)
     assert firm.valid?
@@ -126,6 +137,17 @@ class TestDefaultAutosaveAssociationOnAHasOneAssociation &lt; ActiveRecord::TestCas
 end
 
 class TestDefaultAutosaveAssociationOnABelongsToAssociation &lt; ActiveRecord::TestCase
+  def test_should_save_parent_but_not_invalid_child
+    client = Client.new(:name =&gt; 'Joe (the Plumber)')
+    assert client.valid?
+
+    client.build_firm
+    assert !client.firm.valid?
+
+    assert client.save
+    assert client.firm.new_record?
+  end
+
   def test_save_fails_for_invalid_belongs_to
     assert log = AuditLog.create(:developer_id =&gt; 0, :message =&gt; &quot;&quot;)
 </diff>
      <filename>vendor/rails/activerecord/test/cases/autosave_association_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1756,7 +1756,7 @@ class BasicsTest &lt; ActiveRecord::TestCase
   end
 
   def test_scoped_find_with_group_and_having
-    developers = Developer.with_scope(:find =&gt; { :group =&gt; 'salary', :having =&gt; &quot;SUM(salary) &gt; 10000&quot;, :select =&gt; &quot;SUM(salary) as salary&quot; }) do
+    developers = Developer.with_scope(:find =&gt; { :group =&gt; 'developers.salary', :having =&gt; &quot;SUM(salary) &gt; 10000&quot;, :select =&gt; &quot;SUM(salary) as salary&quot; }) do
       Developer.find(:all)
     end
     assert_equal 3, developers.size</diff>
      <filename>vendor/rails/activerecord/test/cases/base_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,7 @@ class CopyTableTest &lt; ActiveRecord::TestCase
     end
   end
 
-  def test_copy_table(from = 'companies', to = 'companies2', options = {})
+  def test_copy_table(from = 'customers', to = 'customers2', options = {})
     assert_nothing_raised {copy_table(from, to, options)}
     assert_equal row_count(from), row_count(to)
 
@@ -24,11 +24,11 @@ class CopyTableTest &lt; ActiveRecord::TestCase
   end
 
   def test_copy_table_renaming_column
-    test_copy_table('companies', 'companies2',
-        :rename =&gt; {'client_of' =&gt; 'fan_of'}) do |from, to, options|
-      expected = column_values(from, 'client_of')
+    test_copy_table('customers', 'customers2',
+        :rename =&gt; {'name' =&gt; 'person_name'}) do |from, to, options|
+      expected = column_values(from, 'name')
       assert expected.any?, 'only nils in resultset; real values are needed'
-      assert_equal expected, column_values(to, 'fan_of')
+      assert_equal expected, column_values(to, 'person_name')
     end
   end
 </diff>
      <filename>vendor/rails/activerecord/test/cases/copy_table_test_sqlite.rb</filename>
    </modified>
    <modified>
      <diff>@@ -119,6 +119,12 @@ class FinderTest &lt; ActiveRecord::TestCase
       Address.new(existing_address.street + &quot;1&quot;, existing_address.city, existing_address.country))
   end
 
+  def test_exists_with_scoped_include
+    Developer.with_scope(:find =&gt; { :include =&gt; :projects, :order =&gt; &quot;projects.name&quot; }) do
+      assert Developer.exists?
+    end
+  end
+
   def test_find_by_array_of_one_id
     assert_kind_of(Array, Topic.find([ 1 ]))
     assert_equal(1, Topic.find([ 1 ]).length)</diff>
      <filename>vendor/rails/activerecord/test/cases/finder_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -518,6 +518,11 @@ class FoxyFixturesTest &lt; ActiveRecord::TestCase
     assert_equal(Fixtures.identify(:foo), Fixtures.identify(:foo))
   end
 
+  def test_identifies_consistently
+    assert_equal 1281023246, Fixtures.identify(:ruby)
+    assert_equal 2140105598, Fixtures.identify(:sapphire_2)
+  end
+
   TIMESTAMP_COLUMNS = %w(created_at created_on updated_at updated_on)
 
   def test_populates_timestamp_columns</diff>
      <filename>vendor/rails/activerecord/test/cases/fixtures_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,19 +26,19 @@ class JsonSerializationTest &lt; ActiveRecord::TestCase
     NamespacedContact.include_root_in_json = true
     @contact = NamespacedContact.new :name =&gt; 'whatever'
     json = @contact.to_json
-    assert_match %r{^\{&quot;namespaced_contact&quot;: \{}, json
+    assert_match %r{^\{&quot;namespaced_contact&quot;:\{}, json
   end
 
   def test_should_include_root_in_json
     Contact.include_root_in_json = true
     json = @contact.to_json
 
-    assert_match %r{^\{&quot;contact&quot;: \{}, json
-    assert_match %r{&quot;name&quot;: &quot;Konata Izumi&quot;}, json
-    assert_match %r{&quot;age&quot;: 16}, json
-    assert json.include?(%(&quot;created_at&quot;: #{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}))
-    assert_match %r{&quot;awesome&quot;: true}, json
-    assert_match %r{&quot;preferences&quot;: \{&quot;shows&quot;: &quot;anime&quot;\}}, json
+    assert_match %r{^\{&quot;contact&quot;:\{}, json
+    assert_match %r{&quot;name&quot;:&quot;Konata Izumi&quot;}, json
+    assert_match %r{&quot;age&quot;:16}, json
+    assert json.include?(%(&quot;created_at&quot;:#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}))
+    assert_match %r{&quot;awesome&quot;:true}, json
+    assert_match %r{&quot;preferences&quot;:\{&quot;shows&quot;:&quot;anime&quot;\}}, json
   ensure
     Contact.include_root_in_json = false
   end
@@ -46,31 +46,31 @@ class JsonSerializationTest &lt; ActiveRecord::TestCase
   def test_should_encode_all_encodable_attributes
     json = @contact.to_json
 
-    assert_match %r{&quot;name&quot;: &quot;Konata Izumi&quot;}, json
-    assert_match %r{&quot;age&quot;: 16}, json
-    assert json.include?(%(&quot;created_at&quot;: #{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}))
-    assert_match %r{&quot;awesome&quot;: true}, json
-    assert_match %r{&quot;preferences&quot;: \{&quot;shows&quot;: &quot;anime&quot;\}}, json
+    assert_match %r{&quot;name&quot;:&quot;Konata Izumi&quot;}, json
+    assert_match %r{&quot;age&quot;:16}, json
+    assert json.include?(%(&quot;created_at&quot;:#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}))
+    assert_match %r{&quot;awesome&quot;:true}, json
+    assert_match %r{&quot;preferences&quot;:\{&quot;shows&quot;:&quot;anime&quot;\}}, json
   end
 
   def test_should_allow_attribute_filtering_with_only
     json = @contact.to_json(:only =&gt; [:name, :age])
 
-    assert_match %r{&quot;name&quot;: &quot;Konata Izumi&quot;}, json
-    assert_match %r{&quot;age&quot;: 16}, json
-    assert_no_match %r{&quot;awesome&quot;: true}, json
-    assert !json.include?(%(&quot;created_at&quot;: #{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}))
-    assert_no_match %r{&quot;preferences&quot;: \{&quot;shows&quot;: &quot;anime&quot;\}}, json
+    assert_match %r{&quot;name&quot;:&quot;Konata Izumi&quot;}, json
+    assert_match %r{&quot;age&quot;:16}, json
+    assert_no_match %r{&quot;awesome&quot;:true}, json
+    assert !json.include?(%(&quot;created_at&quot;:#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}))
+    assert_no_match %r{&quot;preferences&quot;:\{&quot;shows&quot;:&quot;anime&quot;\}}, json
   end
 
   def test_should_allow_attribute_filtering_with_except
     json = @contact.to_json(:except =&gt; [:name, :age])
 
-    assert_no_match %r{&quot;name&quot;: &quot;Konata Izumi&quot;}, json
-    assert_no_match %r{&quot;age&quot;: 16}, json
-    assert_match %r{&quot;awesome&quot;: true}, json
-    assert json.include?(%(&quot;created_at&quot;: #{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}))
-    assert_match %r{&quot;preferences&quot;: \{&quot;shows&quot;: &quot;anime&quot;\}}, json
+    assert_no_match %r{&quot;name&quot;:&quot;Konata Izumi&quot;}, json
+    assert_no_match %r{&quot;age&quot;:16}, json
+    assert_match %r{&quot;awesome&quot;:true}, json
+    assert json.include?(%(&quot;created_at&quot;:#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}))
+    assert_match %r{&quot;preferences&quot;:\{&quot;shows&quot;:&quot;anime&quot;\}}, json
   end
 
   def test_methods_are_called_on_object
@@ -79,12 +79,12 @@ class JsonSerializationTest &lt; ActiveRecord::TestCase
     def @contact.favorite_quote; &quot;Constraints are liberating&quot;; end
 
     # Single method.
-    assert_match %r{&quot;label&quot;: &quot;Has cheezburger&quot;}, @contact.to_json(:only =&gt; :name, :methods =&gt; :label)
+    assert_match %r{&quot;label&quot;:&quot;Has cheezburger&quot;}, @contact.to_json(:only =&gt; :name, :methods =&gt; :label)
 
     # Both methods.
     methods_json = @contact.to_json(:only =&gt; :name, :methods =&gt; [:label, :favorite_quote])
-    assert_match %r{&quot;label&quot;: &quot;Has cheezburger&quot;}, methods_json
-    assert_match %r{&quot;favorite_quote&quot;: &quot;Constraints are liberating&quot;}, methods_json
+    assert_match %r{&quot;label&quot;:&quot;Has cheezburger&quot;}, methods_json
+    assert_match %r{&quot;favorite_quote&quot;:&quot;Constraints are liberating&quot;}, methods_json
   end
 end
 
@@ -99,42 +99,42 @@ class DatabaseConnectedJsonEncodingTest &lt; ActiveRecord::TestCase
   def test_includes_uses_association_name
     json = @david.to_json(:include =&gt; :posts)
 
-    assert_match %r{&quot;posts&quot;: \[}, json
+    assert_match %r{&quot;posts&quot;:\[}, json
 
-    assert_match %r{&quot;id&quot;: 1}, json
-    assert_match %r{&quot;name&quot;: &quot;David&quot;}, json
+    assert_match %r{&quot;id&quot;:1}, json
+    assert_match %r{&quot;name&quot;:&quot;David&quot;}, json
 
-    assert_match %r{&quot;author_id&quot;: 1}, json
-    assert_match %r{&quot;title&quot;: &quot;Welcome to the weblog&quot;}, json
-    assert_match %r{&quot;body&quot;: &quot;Such a lovely day&quot;}, json
+    assert_match %r{&quot;author_id&quot;:1}, json
+    assert_match %r{&quot;title&quot;:&quot;Welcome to the weblog&quot;}, json
+    assert_match %r{&quot;body&quot;:&quot;Such a lovely day&quot;}, json
 
-    assert_match %r{&quot;title&quot;: &quot;So I was thinking&quot;}, json
-    assert_match %r{&quot;body&quot;: &quot;Like I hopefully always am&quot;}, json
+    assert_match %r{&quot;title&quot;:&quot;So I was thinking&quot;}, json
+    assert_match %r{&quot;body&quot;:&quot;Like I hopefully always am&quot;}, json
   end
 
   def test_includes_uses_association_name_and_applies_attribute_filters
     json = @david.to_json(:include =&gt; { :posts =&gt; { :only =&gt; :title } })
 
-    assert_match %r{&quot;name&quot;: &quot;David&quot;}, json
-    assert_match %r{&quot;posts&quot;: \[}, json
+    assert_match %r{&quot;name&quot;:&quot;David&quot;}, json
+    assert_match %r{&quot;posts&quot;:\[}, json
 
-    assert_match %r{&quot;title&quot;: &quot;Welcome to the weblog&quot;}, json
-    assert_no_match %r{&quot;body&quot;: &quot;Such a lovely day&quot;}, json
+    assert_match %r{&quot;title&quot;:&quot;Welcome to the weblog&quot;}, json
+    assert_no_match %r{&quot;body&quot;:&quot;Such a lovely day&quot;}, json
 
-    assert_match %r{&quot;title&quot;: &quot;So I was thinking&quot;}, json
-    assert_no_match %r{&quot;body&quot;: &quot;Like I hopefully always am&quot;}, json
+    assert_match %r{&quot;title&quot;:&quot;So I was thinking&quot;}, json
+    assert_no_match %r{&quot;body&quot;:&quot;Like I hopefully always am&quot;}, json
   end
 
   def test_includes_fetches_second_level_associations
     json = @david.to_json(:include =&gt; { :posts =&gt; { :include =&gt; { :comments =&gt; { :only =&gt; :body } } } })
 
-    assert_match %r{&quot;name&quot;: &quot;David&quot;}, json
-    assert_match %r{&quot;posts&quot;: \[}, json
+    assert_match %r{&quot;name&quot;:&quot;David&quot;}, json
+    assert_match %r{&quot;posts&quot;:\[}, json
 
-    assert_match %r{&quot;comments&quot;: \[}, json
-    assert_match %r{\{&quot;body&quot;: &quot;Thank you again for the welcome&quot;\}}, json
-    assert_match %r{\{&quot;body&quot;: &quot;Don't think too hard&quot;\}}, json
-    assert_no_match %r{&quot;post_id&quot;: }, json
+    assert_match %r{&quot;comments&quot;:\[}, json
+    assert_match %r{\{&quot;body&quot;:&quot;Thank you again for the welcome&quot;\}}, json
+    assert_match %r{\{&quot;body&quot;:&quot;Don't think too hard&quot;\}}, json
+    assert_no_match %r{&quot;post_id&quot;:}, json
   end
 
   def test_includes_fetches_nth_level_associations
@@ -151,11 +151,11 @@ class DatabaseConnectedJsonEncodingTest &lt; ActiveRecord::TestCase
         }
     })
 
-    assert_match %r{&quot;name&quot;: &quot;David&quot;}, json
-    assert_match %r{&quot;posts&quot;: \[}, json
+    assert_match %r{&quot;name&quot;:&quot;David&quot;}, json
+    assert_match %r{&quot;posts&quot;:\[}, json
 
-    assert_match %r{&quot;taggings&quot;: \[}, json
-    assert_match %r{&quot;tag&quot;: \{&quot;name&quot;: &quot;General&quot;\}}, json
+    assert_match %r{&quot;taggings&quot;:\[}, json
+    assert_match %r{&quot;tag&quot;:\{&quot;name&quot;:&quot;General&quot;\}}, json
   end
 
   def test_should_not_call_methods_on_associations_that_dont_respond
@@ -163,20 +163,20 @@ class DatabaseConnectedJsonEncodingTest &lt; ActiveRecord::TestCase
     json = @david.to_json(:include =&gt; :posts, :methods =&gt; :favorite_quote)
 
     assert !@david.posts.first.respond_to?(:favorite_quote)
-    assert_match %r{&quot;favorite_quote&quot;: &quot;Constraints are liberating&quot;}, json
-    assert_equal %r{&quot;favorite_quote&quot;: }.match(json).size, 1
+    assert_match %r{&quot;favorite_quote&quot;:&quot;Constraints are liberating&quot;}, json
+    assert_equal %r{&quot;favorite_quote&quot;:}.match(json).size, 1
   end
 
   def test_should_allow_only_option_for_list_of_authors
     authors = [@david, @mary]
 
-    assert_equal %([{&quot;name&quot;: &quot;David&quot;}, {&quot;name&quot;: &quot;Mary&quot;}]), authors.to_json(:only =&gt; :name)
+    assert_equal %([{&quot;name&quot;:&quot;David&quot;},{&quot;name&quot;:&quot;Mary&quot;}]), authors.to_json(:only =&gt; :name)
   end
 
   def test_should_allow_except_option_for_list_of_authors
     authors = [@david, @mary]
 
-    assert_equal %([{&quot;id&quot;: 1}, {&quot;id&quot;: 2}]), authors.to_json(:except =&gt; [:name, :author_address_id, :author_address_extra_id])
+    assert_equal %([{&quot;id&quot;:1},{&quot;id&quot;:2}]), authors.to_json(:except =&gt; [:name, :author_address_id, :author_address_extra_id])
   end
 
   def test_should_allow_includes_for_list_of_authors
@@ -188,8 +188,8 @@ class DatabaseConnectedJsonEncodingTest &lt; ActiveRecord::TestCase
       }
     )
 
-    ['&quot;name&quot;: &quot;David&quot;', '&quot;posts&quot;: [', '{&quot;id&quot;: 1}', '{&quot;id&quot;: 2}', '{&quot;id&quot;: 4}',
-     '{&quot;id&quot;: 5}', '{&quot;id&quot;: 6}', '&quot;name&quot;: &quot;Mary&quot;', '&quot;posts&quot;: [{&quot;id&quot;: 7}]'].each do |fragment|
+    ['&quot;name&quot;:&quot;David&quot;', '&quot;posts&quot;:[', '{&quot;id&quot;:1}', '{&quot;id&quot;:2}', '{&quot;id&quot;:4}',
+     '{&quot;id&quot;:5}', '{&quot;id&quot;:6}', '&quot;name&quot;:&quot;Mary&quot;', '&quot;posts&quot;:[{&quot;id&quot;:7}]'].each do |fragment|
       assert json.include?(fragment), json
      end
   end
@@ -200,6 +200,6 @@ class DatabaseConnectedJsonEncodingTest &lt; ActiveRecord::TestCase
       2 =&gt; @mary
     }
 
-    assert_equal %({&quot;1&quot;: {&quot;name&quot;: &quot;David&quot;}}), authors_hash.to_json(:only =&gt; [1, :name])
+    assert_equal %({&quot;1&quot;:{&quot;name&quot;:&quot;David&quot;}}), authors_hash.to_json(:only =&gt; [1, :name])
   end
 end</diff>
      <filename>vendor/rails/activerecord/test/cases/json_serialization_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -591,6 +591,16 @@ class DefaultScopingTest &lt; ActiveRecord::TestCase
     assert_equal expected, received
   end
 
+  def test_default_scope_with_conditions_string
+    assert_equal Developer.find_all_by_name('David').map(&amp;:id).sort, DeveloperCalledDavid.all.map(&amp;:id).sort
+    assert_equal nil, DeveloperCalledDavid.create!.name
+  end
+
+  def test_default_scope_with_conditions_hash
+    assert_equal Developer.find_all_by_name('Jamis').map(&amp;:id).sort, DeveloperCalledJamis.all.map(&amp;:id).sort
+    assert_equal 'Jamis', DeveloperCalledJamis.create!.name
+  end
+
   def test_default_scoping_with_threads
     scope = [{ :create =&gt; {}, :find =&gt; { :order =&gt; 'salary DESC' } }]
 
@@ -628,9 +638,9 @@ class DefaultScopingTest &lt; ActiveRecord::TestCase
     assert_equal expected, received
   end
 
-  def test_named_scope
-    expected = Developer.find(:all, :order =&gt; 'salary DESC, name DESC').collect { |dev| dev.salary }
-    received = DeveloperOrderedBySalary.by_name.find(:all).collect { |dev| dev.salary }
+  def test_named_scope_overwrites_default
+    expected = Developer.find(:all, :order =&gt; 'name DESC').collect { |dev| dev.name }
+    received = DeveloperOrderedBySalary.by_name.find(:all).collect { |dev| dev.name }
     assert_equal expected, received
   end
 </diff>
      <filename>vendor/rails/activerecord/test/cases/method_scoping_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,6 +22,11 @@ class SchemaDumperTest &lt; ActiveRecord::TestCase
     assert_no_match %r{create_table &quot;sqlite_sequence&quot;}, output
   end
 
+  def test_schema_dump_includes_camelcase_table_name
+    output = standard_dump
+    assert_match %r{create_table &quot;CamelCase&quot;}, output
+  end
+
   def assert_line_up(lines, pattern, required = false)
     return assert(true) if lines.empty?
     matches = lines.map { |line| line.match(pattern) }
@@ -147,6 +152,11 @@ class SchemaDumperTest &lt; ActiveRecord::TestCase
     end
   end
 
+  def test_schema_dumps_index_columns_in_right_order
+    index_definition = standard_dump.split(/\n/).grep(/add_index.*companies/).first.strip
+    assert_equal 'add_index &quot;companies&quot;, [&quot;firm_id&quot;, &quot;type&quot;, &quot;rating&quot;, &quot;ruby_type&quot;], :name =&gt; &quot;company_index&quot;', index_definition
+  end
+
   if current_adapter?(:MysqlAdapter)
     def test_schema_dump_should_not_add_default_value_for_mysql_text_field
       output = standard_dump</diff>
      <filename>vendor/rails/activerecord/test/cases/schema_dumper_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,7 @@ class SchemaTest &lt; ActiveRecord::TestCase
   SCHEMA_NAME = 'test_schema'
   SCHEMA2_NAME = 'test_schema2'
   TABLE_NAME = 'things'
+  CAPITALIZED_TABLE_NAME = 'Things'
   INDEX_A_NAME = 'a_index_things_on_name'
   INDEX_B_NAME = 'b_index_things_on_different_columns_in_each_schema'
   INDEX_A_COLUMN = 'name'
@@ -18,9 +19,27 @@ class SchemaTest &lt; ActiveRecord::TestCase
     'moment timestamp without time zone default now()'
   ]
 
+  class Thing1 &lt; ActiveRecord::Base
+    set_table_name &quot;test_schema.things&quot;
+  end
+
+  class Thing2 &lt; ActiveRecord::Base
+    set_table_name &quot;test_schema2.things&quot;
+  end
+
+  class Thing3 &lt; ActiveRecord::Base
+    set_table_name 'test_schema.&quot;things.table&quot;'
+  end
+
+  class Thing4 &lt; ActiveRecord::Base
+    set_table_name 'test_schema.&quot;Things&quot;'
+  end
+
   def setup
     @connection = ActiveRecord::Base.connection
     @connection.execute &quot;CREATE SCHEMA #{SCHEMA_NAME} CREATE TABLE #{TABLE_NAME} (#{COLUMNS.join(',')})&quot;
+    @connection.execute &quot;CREATE TABLE #{SCHEMA_NAME}.\&quot;#{TABLE_NAME}.table\&quot; (#{COLUMNS.join(',')})&quot;
+    @connection.execute &quot;CREATE TABLE #{SCHEMA_NAME}.\&quot;#{CAPITALIZED_TABLE_NAME}\&quot; (#{COLUMNS.join(',')})&quot;
     @connection.execute &quot;CREATE SCHEMA #{SCHEMA2_NAME} CREATE TABLE #{TABLE_NAME} (#{COLUMNS.join(',')})&quot;
     @connection.execute &quot;CREATE INDEX #{INDEX_A_NAME} ON #{SCHEMA_NAME}.#{TABLE_NAME}  USING btree (#{INDEX_A_COLUMN});&quot;
     @connection.execute &quot;CREATE INDEX #{INDEX_A_NAME} ON #{SCHEMA2_NAME}.#{TABLE_NAME}  USING btree (#{INDEX_A_COLUMN});&quot;
@@ -39,6 +58,12 @@ class SchemaTest &lt; ActiveRecord::TestCase
     end
   end
 
+  def test_with_schema_prefixed_capitalized_table_name
+    assert_nothing_raised do
+      assert_equal COLUMNS, columns(&quot;#{SCHEMA_NAME}.#{CAPITALIZED_TABLE_NAME}&quot;)
+    end
+  end
+
   def test_with_schema_search_path
     assert_nothing_raised do
       with_schema_search_path(SCHEMA_NAME) do
@@ -47,6 +72,47 @@ class SchemaTest &lt; ActiveRecord::TestCase
     end
   end
 
+
+  def test_proper_encoding_of_table_name
+    assert_equal '&quot;table_name&quot;', @connection.quote_table_name('table_name')
+    assert_equal '&quot;table.name&quot;', @connection.quote_table_name('&quot;table.name&quot;')
+    assert_equal '&quot;schema_name&quot;.&quot;table_name&quot;', @connection.quote_table_name('schema_name.table_name')
+    assert_equal '&quot;schema_name&quot;.&quot;table.name&quot;', @connection.quote_table_name('schema_name.&quot;table.name&quot;')
+    assert_equal '&quot;schema.name&quot;.&quot;table_name&quot;', @connection.quote_table_name('&quot;schema.name&quot;.table_name')
+    assert_equal '&quot;schema.name&quot;.&quot;table.name&quot;', @connection.quote_table_name('&quot;schema.name&quot;.&quot;table.name&quot;')
+  end
+
+  def test_classes_with_qualified_schema_name
+    assert_equal 0, Thing1.count
+    assert_equal 0, Thing2.count
+    assert_equal 0, Thing3.count
+    assert_equal 0, Thing4.count
+
+    Thing1.create(:id =&gt; 1, :name =&gt; &quot;thing1&quot;, :email =&gt; &quot;thing1@localhost&quot;, :moment =&gt; Time.now)
+    assert_equal 1, Thing1.count
+    assert_equal 0, Thing2.count
+    assert_equal 0, Thing3.count
+    assert_equal 0, Thing4.count
+
+    Thing2.create(:id =&gt; 1, :name =&gt; &quot;thing1&quot;, :email =&gt; &quot;thing1@localhost&quot;, :moment =&gt; Time.now)
+    assert_equal 1, Thing1.count
+    assert_equal 1, Thing2.count
+    assert_equal 0, Thing3.count
+    assert_equal 0, Thing4.count
+
+    Thing3.create(:id =&gt; 1, :name =&gt; &quot;thing1&quot;, :email =&gt; &quot;thing1@localhost&quot;, :moment =&gt; Time.now)
+    assert_equal 1, Thing1.count
+    assert_equal 1, Thing2.count
+    assert_equal 1, Thing3.count
+    assert_equal 0, Thing4.count
+
+    Thing4.create(:id =&gt; 1, :name =&gt; &quot;thing1&quot;, :email =&gt; &quot;thing1@localhost&quot;, :moment =&gt; Time.now)
+    assert_equal 1, Thing1.count
+    assert_equal 1, Thing2.count
+    assert_equal 1, Thing3.count
+    assert_equal 1, Thing4.count
+  end
+
   def test_raise_on_unquoted_schema_name
     assert_raise(ActiveRecord::StatementInvalid) do
       with_schema_search_path '$user,public'
@@ -69,6 +135,16 @@ class SchemaTest &lt; ActiveRecord::TestCase
     do_dump_index_tests_for_schema(SCHEMA2_NAME, INDEX_A_COLUMN, INDEX_B_COLUMN_S2)
   end
 
+  def test_with_uppercase_index_name
+    ActiveRecord::Base.connection.execute &quot;CREATE INDEX \&quot;things_Index\&quot; ON #{SCHEMA_NAME}.things (name)&quot;
+    assert_nothing_raised { ActiveRecord::Base.connection.remove_index :things, :name =&gt; &quot;#{SCHEMA_NAME}.things_Index&quot;}
+
+    ActiveRecord::Base.connection.execute &quot;CREATE INDEX \&quot;things_Index\&quot; ON #{SCHEMA_NAME}.things (name)&quot;
+    ActiveRecord::Base.connection.schema_search_path = SCHEMA_NAME
+    assert_nothing_raised { ActiveRecord::Base.connection.remove_index :things, :name =&gt; &quot;things_Index&quot;}
+    ActiveRecord::Base.connection.schema_search_path = &quot;public&quot;
+  end
+
   private
     def columns(table_name)
       @connection.send(:column_definitions, table_name).map do |name, type, default|</diff>
      <filename>vendor/rails/activerecord/test/cases/schema_test_postgresql.rb</filename>
    </modified>
    <modified>
      <diff>@@ -25,6 +25,8 @@ class Author &lt; ActiveRecord::Base
   has_many :comments_with_order_and_conditions, :through =&gt; :posts, :source =&gt; :comments, :order =&gt; 'comments.body', :conditions =&gt; &quot;comments.body like 'Thank%'&quot;
   has_many :comments_with_include, :through =&gt; :posts, :source =&gt; :comments, :include =&gt; :post
 
+  has_many :thinking_posts, :class_name =&gt; 'Post', :conditions =&gt; { :title =&gt; 'So I was thinking' }, :dependent =&gt; :delete_all
+  has_many :welcome_posts,  :class_name =&gt; 'Post', :conditions =&gt; { :title =&gt; 'Welcome to the weblog' }
 
   has_many :comments_desc, :through =&gt; :posts, :source =&gt; :comments, :order =&gt; 'comments.id DESC'
   has_many :limited_comments, :through =&gt; :posts, :source =&gt; :comments, :limit =&gt; 1</diff>
      <filename>vendor/rails/activerecord/test/models/author.rb</filename>
    </modified>
    <modified>
      <diff>@@ -78,13 +78,6 @@ class DependentFirm &lt; Company
   has_many :companies, :foreign_key =&gt; 'client_of', :order =&gt; &quot;id&quot;, :dependent =&gt; :nullify
 end
 
-class ExclusivelyDependentFirm &lt; Company
-  has_one :account, :foreign_key =&gt; &quot;firm_id&quot;, :dependent =&gt; :delete
-  has_many :dependent_sanitized_conditional_clients_of_firm, :foreign_key =&gt; &quot;client_of&quot;, :class_name =&gt; &quot;Client&quot;, :order =&gt; &quot;id&quot;, :dependent =&gt; :delete_all, :conditions =&gt; &quot;name = 'BigShot Inc.'&quot;
-  has_many :dependent_conditional_clients_of_firm, :foreign_key =&gt; &quot;client_of&quot;, :class_name =&gt; &quot;Client&quot;, :order =&gt; &quot;id&quot;, :dependent =&gt; :delete_all, :conditions =&gt; [&quot;name = ?&quot;, 'BigShot Inc.']
-  has_many :dependent_hash_conditional_clients_of_firm, :foreign_key =&gt; &quot;client_of&quot;, :class_name =&gt; &quot;Client&quot;, :order =&gt; &quot;id&quot;, :dependent =&gt; :delete_all, :conditions =&gt; {:name =&gt; 'BigShot Inc.'}
-end
-
 class Client &lt; Company
   belongs_to :firm, :foreign_key =&gt; &quot;client_of&quot;
   belongs_to :firm_with_basic_id, :class_name =&gt; &quot;Firm&quot;, :foreign_key =&gt; &quot;firm_id&quot;
@@ -125,6 +118,12 @@ class Client &lt; Company
   end
 end
 
+class ExclusivelyDependentFirm &lt; Company
+  has_one :account, :foreign_key =&gt; &quot;firm_id&quot;, :dependent =&gt; :delete
+  has_many :dependent_sanitized_conditional_clients_of_firm, :foreign_key =&gt; &quot;client_of&quot;, :class_name =&gt; &quot;Client&quot;, :order =&gt; &quot;id&quot;, :dependent =&gt; :delete_all, :conditions =&gt; &quot;name = 'BigShot Inc.'&quot;
+  has_many :dependent_conditional_clients_of_firm, :foreign_key =&gt; &quot;client_of&quot;, :class_name =&gt; &quot;Client&quot;, :order =&gt; &quot;id&quot;, :dependent =&gt; :delete_all, :conditions =&gt; [&quot;name = ?&quot;, 'BigShot Inc.']
+  has_many :dependent_hash_conditional_clients_of_firm, :foreign_key =&gt; &quot;client_of&quot;, :class_name =&gt; &quot;Client&quot;, :order =&gt; &quot;id&quot;, :dependent =&gt; :delete_all, :conditions =&gt; {:name =&gt; 'BigShot Inc.'}
+end
 
 class SpecialClient &lt; Client
 end</diff>
      <filename>vendor/rails/activerecord/test/models/company.rb</filename>
    </modified>
    <modified>
      <diff>@@ -89,3 +89,13 @@ class DeveloperOrderedBySalary &lt; ActiveRecord::Base
     end
   end
 end
+
+class DeveloperCalledDavid &lt; ActiveRecord::Base
+  self.table_name = 'developers'
+  default_scope :conditions =&gt; &quot;name = 'David'&quot;
+end
+
+class DeveloperCalledJamis &lt; ActiveRecord::Base
+  self.table_name = 'developers'
+  default_scope :conditions =&gt; { :name =&gt; 'Jamis' }
+end</diff>
      <filename>vendor/rails/activerecord/test/models/developer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 class Pet &lt; ActiveRecord::Base
   set_primary_key :pet_id
-  belongs_to :owner
+  belongs_to :owner, :touch =&gt; true
   has_many :toys
 end</diff>
      <filename>vendor/rails/activerecord/test/models/pet.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,7 +13,7 @@ class Project &lt; ActiveRecord::Base
                             :after_add =&gt; Proc.new {|o, r| o.developers_log &lt;&lt; &quot;after_adding#{r.id || '&lt;new&gt;'}&quot;},
                             :before_remove =&gt; Proc.new {|o, r| o.developers_log &lt;&lt; &quot;before_removing#{r.id}&quot;},
                             :after_remove =&gt; Proc.new {|o, r| o.developers_log &lt;&lt; &quot;after_removing#{r.id}&quot;}
-  has_and_belongs_to_many :well_payed_salary_groups, :class_name =&gt; &quot;Developer&quot;, :group =&gt; &quot;salary&quot;, :having =&gt; &quot;SUM(salary) &gt; 10000&quot;, :select =&gt; &quot;SUM(salary) as salary&quot;
+  has_and_belongs_to_many :well_payed_salary_groups, :class_name =&gt; &quot;Developer&quot;, :group =&gt; &quot;developers.salary&quot;, :having =&gt; &quot;SUM(salary) &gt; 10000&quot;, :select =&gt; &quot;SUM(salary) as salary&quot;
 
   attr_accessor :developers_log
 </diff>
      <filename>vendor/rails/activerecord/test/models/project.rb</filename>
    </modified>
    <modified>
      <diff>@@ -68,6 +68,10 @@ ActiveRecord::Schema.define do
     t.boolean :value
   end
 
+  create_table &quot;CamelCase&quot;, :force =&gt; true do |t|
+    t.string :name
+  end
+
   create_table :categories, :force =&gt; true do |t|
     t.string :name, :null =&gt; false
     t.string :type
@@ -114,6 +118,8 @@ ActiveRecord::Schema.define do
     t.integer :rating, :default =&gt; 1
   end
 
+  add_index :companies, [:firm_id, :type, :rating, :ruby_type], :name =&gt; &quot;company_index&quot;
+
   create_table :computers, :force =&gt; true do |t|
     t.integer :developer, :null =&gt; false
     t.integer :extendedWarranty, :null =&gt; false
@@ -281,6 +287,8 @@ ActiveRecord::Schema.define do
 
   create_table :owners, :primary_key =&gt; :owner_id ,:force =&gt; true do |t|
     t.string :name
+    t.column :updated_at, :datetime
+    t.column :happy_at,   :datetime
   end
 
 </diff>
      <filename>vendor/rails/activerecord/test/schema/schema.rb</filename>
    </modified>
    <modified>
      <diff>@@ -832,7 +832,7 @@ module ActiveResource
       !new? &amp;&amp; self.class.exists?(to_param, :params =&gt; prefix_options)
     end
 
-    # A method to convert the the resource to an XML string.
+     # Converts the resource to an XML string representation.
     #
     # ==== Options
     # The +options+ parameter is handed off to the +to_xml+ method on each
@@ -841,7 +841,14 @@ module ActiveResource
     #
     # * &lt;tt&gt;:indent&lt;/tt&gt; - Set the indent level for the XML output (default is +2+).
     # * &lt;tt&gt;:dasherize&lt;/tt&gt; - Boolean option to determine whether or not element names should
-    #   replace underscores with dashes (default is &lt;tt&gt;false&lt;/tt&gt;).
+    #   replace underscores with dashes. Default is &lt;tt&gt;true&lt;/tt&gt;. The default can be set to &lt;tt&gt;false&lt;/tt&gt;
+    #   by setting the module attribute &lt;tt&gt;ActiveSupport.dasherize_xml = false&lt;/tt&gt; in an initializer. Because save
+    #   uses this method, and there are no options on save, then you will have to set the default if you don't
+    #   want underscores in element names to become dashes when the resource is saved. This is important when
+    #   integrating with non-Rails applications.
+    # * &lt;tt&gt;:camelize&lt;/tt&gt; - Boolean option to determine whether or not element names should be converted
+    #   to camel case, e.g some_name to SomeName. Default is &lt;tt&gt;false&lt;/tt&gt;. Like &lt;tt&gt;:dasherize&lt;/tt&gt; you can
+    #   change the default by setting the module attribute &lt;tt&gt;ActiveSupport.camelise_xml = true&lt;/tt&gt; in an initializer.
     # * &lt;tt&gt;:skip_instruct&lt;/tt&gt; - Toggle skipping the +instruct!+ call on the XML builder
     #   that generates the XML declaration (default is &lt;tt&gt;false&lt;/tt&gt;).
     #
@@ -887,9 +894,12 @@ module ActiveResource
     #   person.to_json(:except =&gt; [&quot;first_name&quot;])
     #   # =&gt; {&quot;last_name&quot;: &quot;Smith&quot;}
     def to_json(options={})
-      attributes.to_json(options)
+      ActiveSupport::JSON.encode(attributes, options)
     end
 
+    # For compatibility with ActiveSupport::JSON.encode
+    alias rails_to_json to_json
+
     # Returns the serialized string representation of the resource in the configured
     # serialization format specified in ActiveResource::Base.format. The options
     # applicable depend on the configured encoding format.</diff>
      <filename>vendor/rails/activeresource/lib/active_resource/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,8 @@
+*2.3.3 (pending)*
+
+* Allow MemCacheStore to be initialized with a MemCache-like object instead of addresses and options [Bryan Helmkamp]
+
+
 *2.3.2 [Final] (March 15, 2009)*
 
 * XmlMini supports LibXML and Nokogiri backends.  #2084, #2190 [Bart ten Brinke, Aaron Patterson]</diff>
      <filename>vendor/rails/activesupport/CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -23,7 +23,12 @@ module ActiveSupport
         DELETED     = &quot;DELETED\r\n&quot;
       end
 
-      attr_reader :addresses
+      def self.build_mem_cache(*addresses)
+        addresses = addresses.flatten
+        options = addresses.extract_options!
+        addresses = [&quot;localhost&quot;] if addresses.empty?
+        MemCache.new(addresses, options)
+      end
 
       # Creates a new MemCacheStore object, with the given memcached server
       # addresses. Each address is either a host name, or a host-with-port string
@@ -34,15 +39,20 @@ module ActiveSupport
       # If no addresses are specified, then MemCacheStore will connect to
       # localhost port 11211 (the default memcached port).
       def initialize(*addresses)
-        addresses = addresses.flatten
-        options = addresses.extract_options!
-        addresses = [&quot;localhost&quot;] if addresses.empty?
-        @addresses = addresses
-        @data = MemCache.new(addresses, options)
+        if addresses.first.respond_to?(:get)
+          @data = addresses.first
+        else
+          @data = self.class.build_mem_cache(*addresses)
+        end
 
         extend Strategy::LocalCache
       end
 
+      # Reads multiple keys from the cache.
+      def read_multi(*keys)
+        @data.get_multi keys
+      end
+
       def read(key, options = nil) # :nodoc:
         super
         @data.get(key, raw?(options))</diff>
      <filename>vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 module ActiveSupport #:nodoc:
   module CoreExtensions #:nodoc:
     module Date #:nodoc:
-      # Enables the use of time calculations within Time itself
+      # Enables the use of time calculations within Date itself
       module Calculations
         def self.included(base) #:nodoc:
           base.extend ClassMethods</diff>
      <filename>vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,14 @@
 require 'date'
+require 'active_support/core_ext/module/attribute_accessors'
 
 module ActiveSupport #:nodoc:
+  # these accessors are here because people using ActiveResource and REST to integrate with other systems
+  # have to be able to control the default behavior of rename_key. dasherize_xml is set to true to emulate
+  # existing behavior. In a future version it should be set to false by default.
+  mattr_accessor :dasherize_xml
+  mattr_accessor :camelize_xml
+  self.dasherize_xml = true
+  self.camelize_xml  = false
   module CoreExtensions #:nodoc:
     module Hash #:nodoc:
       module Conversions
@@ -143,10 +151,11 @@ module ActiveSupport #:nodoc:
         end
 
         def rename_key(key, options = {})
-          camelize = options.has_key?(:camelize) &amp;&amp; options[:camelize]
-          dasherize = !options.has_key?(:dasherize) || options[:dasherize]
+          camelize  = options.has_key?(:camelize) ? options[:camelize]   : ActiveSupport.camelize_xml
+          dasherize = options.has_key?(:dasherize) ? options[:dasherize] : ActiveSupport.dasherize_xml
           key = key.camelize if camelize
-          dasherize ? key.dasherize : key
+          key = key.dasherize if dasherize
+          key
         end
 
         module ClassMethods
@@ -221,7 +230,7 @@ module ActiveSupport #:nodoc:
               case params.class.to_s
                 when &quot;Hash&quot;
                   params.inject({}) do |h,(k,v)|
-                    h[k.to_s.underscore.tr(&quot;-&quot;, &quot;_&quot;)] = unrename_keys(v)
+                    h[k.to_s.tr(&quot;-&quot;, &quot;_&quot;)] = unrename_keys(v)
                     h
                   end
                 when &quot;Array&quot;</diff>
      <filename>vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -41,9 +41,15 @@ module ActiveSupport #:nodoc:
           #   &quot;hello&quot;.first(2)  # =&gt; &quot;he&quot;
           #   &quot;hello&quot;.first(10) # =&gt; &quot;hello&quot;
           def first(limit = 1)
-            mb_chars[0..(limit - 1)].to_s
+            if limit == 0
+              ''
+            elsif limit &gt;= size
+              self
+            else
+              mb_chars[0...limit].to_s
+            end
           end
-          
+
           # Returns the last character of the string or the last +limit+ characters.
           #
           # Examples: 
@@ -51,7 +57,13 @@ module ActiveSupport #:nodoc:
           #   &quot;hello&quot;.last(2)  # =&gt; &quot;lo&quot;
           #   &quot;hello&quot;.last(10) # =&gt; &quot;hello&quot;
           def last(limit = 1)
-            (mb_chars[(-limit)..-1] || self).to_s
+            if limit == 0
+              ''
+            elsif limit &gt;= size
+              self
+            else
+              mb_chars[(-limit)..-1].to_s
+            end
           end
         end
       else</diff>
      <filename>vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,71 @@
 module ActiveSupport
   # If true, use ISO 8601 format for dates and times. Otherwise, fall back to the Active Support legacy format.
   mattr_accessor :use_standard_json_time_format
+  # Look for and parse json strings that look like ISO 8601 times.
+  mattr_accessor :parse_json_times
 
-  class &lt;&lt; self
-    def escape_html_entities_in_json
-      @escape_html_entities_in_json
+  module JSON
+    # matches YAML-formatted dates
+    DATE_REGEX = /^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[ \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?))$/
+
+    module Encoding #:nodoc:
+      mattr_accessor :escape_regex
+
+      ESCAPED_CHARS = {
+        &quot;\010&quot; =&gt;  '\b',
+        &quot;\f&quot;   =&gt;  '\f',
+        &quot;\n&quot;   =&gt;  '\n',
+        &quot;\r&quot;   =&gt;  '\r',
+        &quot;\t&quot;   =&gt;  '\t',
+        '&quot;'    =&gt;  '\&quot;',
+        '\\'   =&gt;  '\\\\',
+        '&gt;'    =&gt;  '\u003E',
+        '&lt;'    =&gt;  '\u003C',
+        '&amp;'    =&gt;  '\u0026'
+      }
+
+      def self.escape(string)
+        json = '&quot;' + string.gsub(escape_regex) { |s| ESCAPED_CHARS[s] }
+        json.force_encoding('ascii-8bit') if respond_to?(:force_encoding)
+        json.gsub(/([\xC0-\xDF][\x80-\xBF]|
+                 [\xE0-\xEF][\x80-\xBF]{2}|
+                 [\xF0-\xF7][\x80-\xBF]{3})+/nx) { |s|
+          s.unpack(&quot;U*&quot;).pack(&quot;n*&quot;).unpack(&quot;H*&quot;)[0].gsub(/.{4}/, '\\\\u\&amp;')
+        } + '&quot;'
+      end
     end
 
+    class &lt;&lt; self
+      delegate :decode, :to =&gt; :backend
+
+      def backend
+        @backend || begin
+          self.backend = &quot;Yaml&quot;
+          @backend
+        end
+      end
+
+      def backend=(name)
+        if name.is_a?(Module)
+          @backend = name
+        else
+          require &quot;active_support/json/backends/#{name.to_s.downcase}.rb&quot;
+          @backend = ActiveSupport::JSON::Backends::const_get(name)
+        end
+      end
+    
+      def with_backend(name)
+        old_backend, self.backend = backend, name
+        yield
+      ensure
+        self.backend = old_backend
+      end
+    end
+  end
+
+  class &lt;&lt; self
+    attr_reader :escape_html_entities_in_json
+
     def escape_html_entities_in_json=(value)
       ActiveSupport::JSON::Encoding.escape_regex = \
         if value
@@ -19,5 +78,6 @@ module ActiveSupport
   end
 end
 
+ActiveSupport.escape_html_entities_in_json = true
+
 require 'active_support/json/encoding'
-require 'active_support/json/decoding'</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@ class Date
   #   # With ActiveSupport.use_standard_json_time_format = false
   #   Date.new(2005,2,1).to_json
   #   # =&gt; &quot;2005/02/01&quot;
-  def to_json(options = nil)
+  def rails_to_json(options = nil)
     if ActiveSupport.use_standard_json_time_format
       %(&quot;#{strftime(&quot;%Y-%m-%d&quot;)}&quot;)
     else</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoders/date.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@ class DateTime
   #   # With ActiveSupport.use_standard_json_time_format = false
   #   DateTime.civil(2005,2,1,15,15,10).to_json
   #   # =&gt; &quot;2005/02/01 15:15:10 +0000&quot;
-  def to_json(options = nil)
+  def rails_to_json(options = nil)
     if ActiveSupport.use_standard_json_time_format
       xmlschema.inspect
     else</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoders/date_time.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ module Enumerable
   #   # =&gt; users.to_json(:only =&gt; :name)
   #
   # will pass the &lt;tt&gt;:only =&gt; :name&lt;/tt&gt; option to each user.
-  def to_json(options = {}) #:nodoc:
-    &quot;[#{map { |value| ActiveSupport::JSON.encode(value, options) } * ', '}]&quot;
+  def rails_to_json(options = nil) #:nodoc:
+    &quot;[#{map { |value| ActiveSupport::JSON.encode(value, options) } * ','}]&quot;
   end
 end</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 class FalseClass
-  def to_json(options = nil) #:nodoc:
+  def rails_to_json(options = nil) #:nodoc:
     'false'
   end
 end</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoders/false_class.rb</filename>
    </modified>
    <modified>
      <diff>@@ -28,19 +28,21 @@ class Hash
   # would pass the &lt;tt&gt;:include =&gt; :posts&lt;/tt&gt; option to &lt;tt&gt;users&lt;/tt&gt;,
   # allowing the posts association in the User model to be converted to JSON
   # as well.
-  def to_json(options = {}) #:nodoc:
+  def rails_to_json(options = nil) #:nodoc:
     hash_keys = self.keys
 
-    if except = options[:except]
-      hash_keys = hash_keys - Array.wrap(except)
-    elsif only = options[:only]
-      hash_keys = hash_keys &amp; Array.wrap(only)
+    if options
+      if except = options[:except]
+        hash_keys = hash_keys - Array.wrap(except)
+      elsif only = options[:only]
+        hash_keys = hash_keys &amp; Array.wrap(only)
+      end
     end
 
     result = '{'
     result &lt;&lt; hash_keys.map do |key|
-      &quot;#{ActiveSupport::JSON.encode(key.to_s)}: #{ActiveSupport::JSON.encode(self[key], options)}&quot;
-    end * ', '
+      &quot;#{ActiveSupport::JSON.encode(key.to_s)}:#{ActiveSupport::JSON.encode(self[key], options)}&quot;
+    end * ','
     result &lt;&lt; '}'
   end
 end</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoders/hash.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 class NilClass
-  def to_json(options = nil) #:nodoc:
+  def rails_to_json(options = nil) #:nodoc:
     'null'
   end
 end</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoders/nil_class.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 class Numeric
-  def to_json(options = nil) #:nodoc:
+  def rails_to_json(options = nil) #:nodoc:
     to_s
   end
 end</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoders/numeric.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,8 @@
 class Object
   # Dumps object in JSON (JavaScript Object Notation). See www.json.org for more info.
-  def to_json(options = {})
+  def rails_to_json(options = nil)
     ActiveSupport::JSON.encode(instance_values, options)
   end
+
+  alias to_json rails_to_json
 end</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoders/object.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 class Regexp
-  def to_json(options = nil) #:nodoc:
+  def rails_to_json(options = nil) #:nodoc:
     inspect
   end
 end</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoders/regexp.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,36 +1,5 @@
-module ActiveSupport
-  module JSON
-    module Encoding
-      mattr_accessor :escape_regex
-
-      ESCAPED_CHARS = {
-        &quot;\010&quot; =&gt;  '\b',
-        &quot;\f&quot;   =&gt;  '\f',
-        &quot;\n&quot;   =&gt;  '\n',
-        &quot;\r&quot;   =&gt;  '\r',
-        &quot;\t&quot;   =&gt;  '\t',
-        '&quot;'    =&gt;  '\&quot;',
-        '\\'   =&gt;  '\\\\',
-        '&gt;'    =&gt;  '\u003E',
-        '&lt;'    =&gt;  '\u003C',
-        '&amp;'    =&gt;  '\u0026'
-      }
-    end
-  end
-end
-
-ActiveSupport.escape_html_entities_in_json = true
-
 class String
-  def to_json(options = nil) #:nodoc:
-    json = '&quot;' + gsub(ActiveSupport::JSON::Encoding.escape_regex) { |s|
-      ActiveSupport::JSON::Encoding::ESCAPED_CHARS[s]
-    }
-    json.force_encoding('ascii-8bit') if respond_to?(:force_encoding)
-    json.gsub(/([\xC0-\xDF][\x80-\xBF]|
-             [\xE0-\xEF][\x80-\xBF]{2}|
-             [\xF0-\xF7][\x80-\xBF]{3})+/nx) { |s|
-      s.unpack(&quot;U*&quot;).pack(&quot;n*&quot;).unpack(&quot;H*&quot;)[0].gsub(/.{4}/, '\\\\u\&amp;')
-    } + '&quot;'
+  def rails_to_json(options = nil) #:nodoc:
+    ActiveSupport::JSON::Encoding.escape(self)
   end
 end</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoders/string.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 class Symbol
-  def to_json(options = {}) #:nodoc:
+  def rails_to_json(options = nil) #:nodoc:
     ActiveSupport::JSON.encode(to_s, options)
   end
 end</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoders/symbol.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@ class Time
   #   # With ActiveSupport.use_standard_json_time_format = false
   #   Time.utc(2005,2,1,15,15,10).to_json
   #   # =&gt; &quot;2005/02/01 15:15:10 +0000&quot;
-  def to_json(options = nil)
+  def rails_to_json(options = nil)
     if ActiveSupport.use_standard_json_time_format
       xmlschema.inspect
     else</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoders/time.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 class TrueClass
-  def to_json(options = nil) #:nodoc:
+  def rails_to_json(options = nil) #:nodoc:
     'true'
   end
 end</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoders/true_class.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,11 +4,12 @@ module ActiveSupport
     end
 
     # Converts a Ruby object into a JSON string.
-    def self.encode(value, options = {})
+    def self.encode(value, options = nil)
+      options ||= {}
       seen = (options[:seen] ||= [])
       raise CircularReferenceError, 'object references itself' if seen.include?(value)
       seen &lt;&lt; value
-      value.send(:to_json, options)
+      value.rails_to_json(options)
     ensure
       seen.pop
     end</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/encoding.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,9 +2,11 @@ module ActiveSupport
   module JSON
     # A string that returns itself as its JSON-encoded form.
     class Variable &lt; String
-      def to_json(options=nil)
+      def rails_to_json(options=nil)
         self
       end
+
+      alias to_json rails_to_json
     end
   end
 end</diff>
      <filename>vendor/rails/activesupport/lib/active_support/json/variable.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,6 +10,16 @@ module ActiveSupport
         @keys = []
       end
 
+      def self.[](*args)
+        ordered_hash = new
+        args.each_with_index { |val,ind|
+          # Only every second value is a key.
+          next if ind % 2 != 0
+          ordered_hash[val] = args[ind + 1]
+        }
+        ordered_hash
+      end
+
       def initialize_copy(other)
         super
         # make a deep copy of keys
@@ -57,6 +67,10 @@ module ActiveSupport
         self
       end
 
+      def to_a
+        @keys.map { |key| [ key, self[key] ] }
+      end
+
       def each_key
         @keys.each { |key| yield key }
       end</diff>
      <filename>vendor/rails/activesupport/lib/active_support/ordered_hash.rb</filename>
    </modified>
    <modified>
      <diff>@@ -120,7 +120,7 @@ module ActiveSupport
     #   # With ActiveSupport.use_standard_json_time_format = false
     #   Time.utc(2005,2,1,15,15,10).in_time_zone.to_json
     #   # =&gt; &quot;2005/02/01 15:15:10 +0000&quot;
-    def to_json(options = nil)
+    def rails_to_json(options = nil)
       if ActiveSupport.use_standard_json_time_format
         xmlschema.inspect
       else
@@ -128,6 +128,8 @@ module ActiveSupport
       end
     end
 
+    alias to_json rails_to_json
+
     def to_yaml(options = {})
       if options.kind_of?(YAML::Emitter)
         utc.to_yaml(options)</diff>
      <filename>vendor/rails/activesupport/lib/active_support/time_with_zone.rb</filename>
    </modified>
    <modified>
      <diff>@@ -246,7 +246,7 @@ def copy_with_rewritten_ruby_path(src_file, dest_file)
 end
 
 desc 'Generate guides (for authors), use ONLY=foo to process just &quot;foo.textile&quot;'
-task :guides do
+task :generate_guides do
   ruby &quot;guides/rails_guides.rb&quot;
 end
 
@@ -294,6 +294,7 @@ PKG_FILES = FileList[
   'doc/**/*', 
   'dispatches/**/*', 
   'environments/**/*', 
+  'guides/**/*', 
   'helpers/**/*', 
   'generators/**/*', 
   'html/**/*', 
@@ -320,7 +321,7 @@ spec = Gem::Specification.new do |s|
   s.rdoc_options &lt;&lt; '--exclude' &lt;&lt; '.'
   s.has_rdoc = false
 
-  s.files = PKG_FILES.to_a.delete_if {|f| f.include?('.svn')}
+  s.files = PKG_FILES.to_a.delete_if {|f| f =~ %r{\.svn|guides/output}}
   s.require_path = 'lib'
   s.bindir = &quot;bin&quot;                               # Use these for applications.
   s.executables = [&quot;rails&quot;]
@@ -345,7 +346,7 @@ task :pgem =&gt; [:gem] do
 end
 
 desc &quot;Publish the guides&quot;
-task :pguides =&gt; :guides do
+task :pguides =&gt; :generate_guides do
   mkdir_p 'pkg'
   `tar -czf pkg/guides.gz guides/output`
   Rake::SshFilePublisher.new(&quot;web.rubyonrails.org&quot;, &quot;/u/sites/guides.rubyonrails.org/public&quot;, &quot;pkg&quot;, &quot;guides.gz&quot;).upload</diff>
      <filename>vendor/rails/railties/Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -37,7 +37,7 @@ ActionController::Routing::Routes.draw do |map|
 
   # Install the default routes as the lowest priority.
   # Note: These default routes make all actions in every controller accessible via GET requests. You should
-  # consider removing the them or commenting them out if you're using named routes and resources.
+  # consider removing or commenting them out if you're using named routes and resources.
   map.connect ':controller/:action/:id'
   map.connect ':controller/:action/:id.:format'
 end</diff>
      <filename>vendor/rails/railties/configs/routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,7 +29,7 @@ begin
       printer_class = RubyProf::FlatPrinter
     end
     printer = printer_class.new(results)
-    printer.print($stderr, 0)
+    printer.print($stderr)
   rescue LoadError
     require &quot;prof&quot;
     $stderr.puts 'Using the old ruby-prof extension.'</diff>
      <filename>vendor/rails/railties/lib/commands/performance/profiler.rb</filename>
    </modified>
    <modified>
      <diff>@@ -159,6 +159,8 @@ module Rails
 
       add_support_load_paths
 
+      check_for_unbuilt_gems
+
       load_gems
       load_plugins
 
@@ -306,6 +308,25 @@ module Rails
       end
     end
 
+    def check_for_unbuilt_gems
+      unbuilt_gems = @configuration.gems.select(&amp;:frozen?).reject(&amp;:built?)
+      if unbuilt_gems.size &gt; 0
+        # don't print if the gems:build rake tasks are being run
+        unless $gems_build_rake_task
+          abort &lt;&lt;-end_error
+The following gems have native components that need to be built
+  #{unbuilt_gems.map { |gem| &quot;#{gem.name}  #{gem.requirement}&quot; } * &quot;\n  &quot;}
+
+You're running:
+  ruby #{Gem.ruby_version} at #{Gem.ruby}
+  rubygems #{Gem::RubyGemsVersion} at #{Gem.path * ', '}
+
+Run `rake gems:build` to build the unbuilt gems.
+          end_error
+        end
+      end
+    end
+
     def check_gem_dependencies
       unloaded_gems = @configuration.gems.reject { |g| g.loaded? }
       if unloaded_gems.size &gt; 0
@@ -565,7 +586,7 @@ Run `rake gems:install` to install the missing gems.
       Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths
 
       configuration.middleware.insert_before(
-        :&quot;ActionController::RewindableInput&quot;,
+        :&quot;ActionController::ParamsParser&quot;,
         Rails::Rack::Metal, :if =&gt; Rails::Rack::Metal.metals.any?)
     end
 </diff>
      <filename>vendor/rails/railties/lib/initializer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,6 +29,15 @@ module Rails
       end
     end
 
+    def self.from_directory_name(directory_name)
+      directory_name_parts = File.basename(directory_name).split('-')
+      name    = directory_name_parts[0..-2].join('-')
+      version = directory_name_parts.last
+      self.new(name, :version =&gt; version)
+    rescue ArgumentError =&gt; e
+      raise &quot;Unable to determine gem name and version from '#{directory_name}'&quot;
+    end
+
     def initialize(name, options = {})
       require 'rubygems' unless Object.const_defined?(:Gem)
 
@@ -101,8 +110,12 @@ module Rails
     end
 
     def built?
-      # TODO: If Rubygems ever gives us a way to detect this, we should use it
-      false
+      return false unless frozen?
+      specification.extensions.each do |ext|
+        makefile = File.join(unpacked_gem_directory, File.dirname(ext), 'Makefile')
+        return false unless File.exists?(makefile)
+      end
+      true
     end
 
     def framework_gem?
@@ -155,9 +168,9 @@ module Rails
       specification &amp;&amp; File.exists?(unpacked_gem_directory)
     end
 
-    def build
+    def build(options={})
       require 'rails/gem_builder'
-      unless built?
+      if options[:force] || !built?
         return unless File.exists?(unpacked_specification_filename)
         spec = YAML::load_file(unpacked_specification_filename)
         Rails::GemBuilder.new(spec, unpacked_gem_directory).build_extensions</diff>
      <filename>vendor/rails/railties/lib/rails/gem_dependency.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,7 +26,7 @@ module Rails
 
         load_list.map do |requested_metal|
           if metal = all_metals[requested_metal]
-            require metal
+            require_dependency metal
             requested_metal.constantize
           end
         end.compact</diff>
      <filename>vendor/rails/railties/lib/rails/rack/metal.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,8 +20,16 @@ namespace :gems do
   desc &quot;Build any native extensions for unpacked gems&quot;
   task :build do
     $gems_build_rake_task = true
-    Rake::Task['gems:unpack'].invoke
-    current_gems.each &amp;:build
+    frozen_gems.each &amp;:build
+  end
+
+  namespace :build do
+    desc &quot;Force the build of all gems&quot;
+    task :force do
+      $gems_build_rake_task = true
+      Rake::Task['gems:unpack'].invoke
+      current_gems.each { |gem| gem.build(:force =&gt; true) }
+    end
   end
 
   desc &quot;Installs all required gems.&quot;
@@ -53,6 +61,12 @@ def current_gems
   gems
 end
 
+def frozen_gems
+  Dir[File.join(RAILS_ROOT, 'vendor', 'gems', '*-*')].map do |gem_dir|
+    Rails::GemDependency.from_directory_name(gem_dir)
+  end
+end
+
 def print_gem_status(gem, indent=1)
   code = case
     when gem.framework_gem? then 'R'</diff>
      <filename>vendor/rails/railties/lib/tasks/gems.rake</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>public/index.html</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/rewindable_input.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/adapter/camping.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/basic.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/md5.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/nonce.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/params.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/request.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/openid.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/builder.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/cascade.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/chunked.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/commonlogger.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/conditionalget.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_type.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/deflater.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/directory.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/file.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/evented_mongrel.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/swiftiplied_mongrel.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/thin.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/head.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lobster.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lock.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/methodoverride.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/mime.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/mock.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/recursive.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/reloader.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/request.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/response.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/abstract/id.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/cookie.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/memcache.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/pool.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showexceptions.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showstatus.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/static.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/activerecord/test/fixtures/fixture_database.sqlite3</filename>
    </removed>
    <removed>
      <filename>vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite3</filename>
    </removed>
    <removed>
      <filename>vendor/rails/activesupport/lib/active_support/json/decoding.rb</filename>
    </removed>
    <removed>
      <filename>vendor/rails/railties/configs/empty.log</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>6f9af4bbf745d013de9291f82547af0f83a5b697</id>
    </parent>
  </parents>
  <author>
    <name>Kenneth Kalmer</name>
    <email>kenneth.kalmer@gmail.com</email>
  </author>
  <url>http://github.com/kennethkalmer/powerdns-on-rails/commit/deff98c6e3f5603c8bd6c7fa5c7760ee7f3ab4cf</url>
  <id>deff98c6e3f5603c8bd6c7fa5c7760ee7f3ab4cf</id>
  <committed-date>2009-05-25T05:22:02-07:00</committed-date>
  <authored-date>2009-05-25T05:22:02-07:00</authored-date>
  <message>Updated vendor/rails to solve rack compatibility issues</message>
  <tree>f5c48b8353190a4d82dd58fda2b32c74d9ce334a</tree>
  <committer>
    <name>Kenneth Kalmer</name>
    <email>kenneth.kalmer@gmail.com</email>
  </committer>
</commit>
