[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#781857: unblock (pre-approval): rails/2:4.1.10-1



Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

Hi,

I would like to upload a new upstream version of rails to have it in
jessie.

This is a maintainance upstream release which only contains bug fixes
and associated documentation/test updates.

I realize the diff is way too big, but upstream is pretty conservative
with maintainance releases so I am not too concerned about the changes.
There are no API changes, and no behavior changes other than the bug
fixes themselves.

I am attaching the debdiff against the package in testing in two
formats:

- rails-filtered.diff: debdiff filtered to exclude most of the noise
  such as changes to changelogs, version bumps, unit tests, standalone
  documentation files etc (1694 lines; only 35% of the full diff)
- rails.diff: full debdiff (4746 lines)

rails-filtered.diff can be obtained from rails.diff by running

$ filterdiff --clean -x '*.md' -x '*/test/*' -x '*/*version.rb' -x '*Gemfile*' -x '*.yml' rails.diff

unblock rails/2:4.1.10-1

-- System Information:
Debian Release: 8.0
  APT prefers buildd-unstable
  APT policy: (500, 'buildd-unstable'), (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=pt_BR.UTF-8, LC_CTYPE=pt_BR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

-- 
Antonio Terceiro <terceiro@debian.org>
--- rails-4.1.8/actionpack/lib/action_controller/base.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_controller/base.rb	2015-03-19 13:48:26.000000000 -0300
@@ -44,7 +44,7 @@
   # The full request object is available via the request accessor and is primarily used to query for HTTP headers:
   #
   #   def server_ip
-  #     location = request.env["SERVER_ADDR"]
+  #     location = request.env["REMOTE_ADDR"]
   #     render plain: "This server hosted at #{location}"
   #   end
   #
--- rails-4.1.8/actionpack/lib/action_controller/metal/http_authentication.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_controller/metal/http_authentication.rb	2015-03-19 13:48:26.000000000 -0300
@@ -397,6 +397,7 @@
     #
     #   RewriteRule ^(.*)$ dispatch.fcgi [E=X-HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L]
     module Token
+      TOKEN_KEY = 'token='
       TOKEN_REGEX = /^Token /
       AUTHN_PAIR_DELIMITERS = /(?:,|;|\t+)/
       extend self
@@ -471,7 +472,13 @@
       # pairs by the standardized `:`, `;`, or `\t` delimiters defined in
       # `AUTHN_PAIR_DELIMITERS`.
       def raw_params(auth)
-        auth.sub(TOKEN_REGEX, '').split(/"\s*#{AUTHN_PAIR_DELIMITERS}\s*/)
+        _raw_params = auth.sub(TOKEN_REGEX, '').split(/\s*#{AUTHN_PAIR_DELIMITERS}\s*/)
+
+        if !(_raw_params.first =~ %r{\A#{TOKEN_KEY}})
+          _raw_params[0] = "#{TOKEN_KEY}#{_raw_params.first}"
+        end
+
+        _raw_params
       end
 
       # Encodes the given token and options into an Authorization header value.
@@ -481,7 +488,7 @@
       #
       # Returns String.
       def encode_credentials(token, options = {})
-        values = ["token=#{token.to_s.inspect}"] + options.map do |key, value|
+        values = ["#{TOKEN_KEY}#{token.to_s.inspect}"] + options.map do |key, value|
           "#{key}=#{value.to_s.inspect}"
         end
         "Token #{values * ", "}"
--- rails-4.1.8/actionpack/lib/action_controller/metal/instrumentation.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_controller/metal/instrumentation.rb	2015-03-19 13:48:26.000000000 -0300
@@ -28,10 +28,13 @@
       ActiveSupport::Notifications.instrument("start_processing.action_controller", raw_payload.dup)
 
       ActiveSupport::Notifications.instrument("process_action.action_controller", raw_payload) do |payload|
-        result = super
-        payload[:status] = response.status
-        append_info_to_payload(payload)
-        result
+        begin
+          result = super
+          payload[:status] = response.status
+          result
+        ensure
+          append_info_to_payload(payload)
+        end
       end
     end
 
--- rails-4.1.8/actionpack/lib/action_dispatch/http/mime_negotiation.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_dispatch/http/mime_negotiation.rb	2015-03-19 13:48:26.000000000 -0300
@@ -70,7 +70,7 @@
       def variant=(variant)
         if variant.is_a?(Symbol)
           @variant = [variant]
-        elsif variant.is_a?(Array) && variant.any? && variant.all?{ |v| v.is_a?(Symbol) }
+        elsif variant.nil? || variant.is_a?(Array) && variant.any? && variant.all?{ |v| v.is_a?(Symbol) }
           @variant = variant
         else
           raise ArgumentError, "request.variant must be set to a Symbol or an Array of Symbols, not a #{variant.class}. " \
--- rails-4.1.8/actionpack/lib/action_dispatch/http/parameter_filter.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_dispatch/http/parameter_filter.rb	2015-03-19 13:48:26.000000000 -0300
@@ -56,7 +56,7 @@
             elsif value.is_a?(Array)
               value = value.map { |v| v.is_a?(Hash) ? call(v) : v }
             elsif blocks.any?
-              key = key.dup
+              key = key.dup if key.duplicable?
               value = value.dup if value.duplicable?
               blocks.each { |b| b.call(key, value) }
             end
--- rails-4.1.8/actionpack/lib/action_dispatch/middleware/cookies.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_dispatch/middleware/cookies.rb	2015-03-19 13:48:26.000000000 -0300
@@ -70,11 +70,13 @@
   #   restrict to the domain level. If you use a schema like www.example.com
   #   and want to share session with user.example.com set <tt>:domain</tt>
   #   to <tt>:all</tt>. Make sure to specify the <tt>:domain</tt> option with
-  #   <tt>:all</tt> again when deleting cookies.
+  #   <tt>:all</tt> or <tt>Array</tt> again when deleting cookies.
   #
   #     domain: nil  # Does not sets cookie domain. (default)
   #     domain: :all # Allow the cookie for the top most level
   #                       domain and subdomains.
+  #     domain: %w(.example.com .example.org) # Allow the cookie 
+  #                       for concrete domain names.
   #
   # * <tt>:expires</tt> - The time at which this cookie expires, as a \Time object.
   # * <tt>:secure</tt> - Whether this cookie is only transmitted to HTTPS servers.
@@ -118,7 +120,7 @@
       # the cookie again. This is useful for creating cookies with values that the user is not supposed to change. If a signed
       # cookie was tampered with by the user (or a 3rd party), nil will be returned.
       #
-      # If +secrets.secret_key_base+ and +config.secret_token+ (deprecated) are both set,
+      # If +secrets.secret_key_base+ and +secrets.secret_token+ (deprecated) are both set,
       # legacy cookies signed with the old key generator will be transparently upgraded.
       #
       # This jar requires that you set a suitable secret for the verification on your app's +secrets.secret_key_base+.
@@ -141,7 +143,7 @@
       # Returns a jar that'll automatically encrypt cookie values before sending them to the client and will decrypt them for read.
       # If the cookie was tampered with by the user (or a 3rd party), nil will be returned.
       #
-      # If +secrets.secret_key_base+ and +config.secret_token+ (deprecated) are both set,
+      # If +secrets.secret_key_base+ and +secrets.secret_token+ (deprecated) are both set,
       # legacy cookies signed with the old key generator will be transparently upgraded.
       #
       # This jar requires that you set a suitable secret for the verification on your app's +secrets.secret_key_base+.
@@ -481,7 +483,7 @@
     end
 
     # UpgradeLegacySignedCookieJar is used instead of SignedCookieJar if
-    # config.secret_token and secrets.secret_key_base are both set. It reads
+    # secrets.secret_token and secrets.secret_key_base are both set. It reads
     # legacy cookies signed with the old dummy key generator and re-saves
     # them using the new key generator to provide a smooth upgrade path.
     class UpgradeLegacySignedCookieJar < SignedCookieJar #:nodoc:
@@ -539,7 +541,7 @@
     end
 
     # UpgradeLegacyEncryptedCookieJar is used by ActionDispatch::Session::CookieStore
-    # instead of EncryptedCookieJar if config.secret_token and secrets.secret_key_base
+    # instead of EncryptedCookieJar if secrets.secret_token and secrets.secret_key_base
     # are both set. It reads legacy cookies signed with the old dummy key generator and
     # encrypts and re-saves them using the new key generator to provide a smooth upgrade path.
     class UpgradeLegacyEncryptedCookieJar < EncryptedCookieJar #:nodoc:
--- rails-4.1.8/actionpack/lib/action_dispatch/middleware/flash.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_dispatch/middleware/flash.rb	2015-03-19 13:48:26.000000000 -0300
@@ -129,7 +129,7 @@
       end
 
       def key?(name)
-        @flashes.key? name
+        @flashes.key? name.to_s
       end
 
       def delete(key)
--- rails-4.1.8/actionpack/lib/action_dispatch/routing/route_set.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_dispatch/routing/route_set.rb	2015-03-19 13:48:26.000000000 -0300
@@ -235,12 +235,26 @@
             result = options.dup
 
             if args.size > 0
-              if args.size < keys.size - 1 # take format into account
+              # take format into account
+              if keys.include?(:format)
+                keys_size = keys.size - 1
+              else
+                keys_size = keys.size
+              end
+
+              if args.size < keys_size
                 keys -= t.url_options.keys if t.respond_to?(:url_options)
                 keys -= options.keys
               end
               keys -= inner_options.keys
-              result.merge!(Hash[keys.zip(args)])
+
+              keys.each do |key|
+                value = inner_options.fetch(key) { args.shift }
+
+                unless key == :format && value.nil?
+                  result[key] = value
+                end
+              end
             end
 
             result.merge!(inner_options)
--- rails-4.1.8/actionpack/lib/action_dispatch/testing/test_response.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_dispatch/testing/test_response.rb	2015-03-19 13:48:26.000000000 -0300
@@ -25,5 +25,12 @@
 
     # Was there a server-side error?
     alias_method :error?, :server_error?
+
+    def merge_default_headers(original, *args)
+      # Default headers are already applied, no need to merge them a second time.
+      # This makes sure that default headers, removed in controller actions, will
+      # not be reapplied to the test response.
+      original
+    end
   end
 end
--- rails-4.1.8/actionview/lib/action_view/helpers/form_helper.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionview/lib/action_view/helpers/form_helper.rb	2015-03-19 13:48:26.000000000 -0300
@@ -1142,11 +1142,11 @@
             object_name = model_name_from_record_or_class(object).param_key
           end
 
-          builder = options[:builder] || default_form_builder
+          builder = options[:builder] || default_form_builder_class
           builder.new(object_name, object, self, options)
         end
 
-        def default_form_builder
+        def default_form_builder_class
           builder = ActionView::Base.default_form_builder
           builder.respond_to?(:constantize) ? builder.constantize : builder
         end
@@ -1871,6 +1871,8 @@
   end
 
   ActiveSupport.on_load(:action_view) do
-    cattr_accessor(:default_form_builder) { ::ActionView::Helpers::FormBuilder }
+    cattr_accessor(:default_form_builder, instance_writer: false, instance_reader: false) do
+      ::ActionView::Helpers::FormBuilder
+    end
   end
 end
--- rails-4.1.8/actionview/lib/action_view/helpers/form_tag_helper.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionview/lib/action_view/helpers/form_tag_helper.rb	2015-03-19 13:48:26.000000000 -0300
@@ -133,7 +133,9 @@
             include_blank = ''
           end
 
-          option_tags = content_tag(:option, include_blank, value: '').safe_concat(option_tags)
+          if include_blank
+            option_tags = content_tag(:option, include_blank, value: '').safe_concat(option_tags)
+          end
         end
 
         if prompt = options.delete(:prompt)
--- rails-4.1.8/actionview/lib/action_view/helpers/translation_helper.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionview/lib/action_view/helpers/translation_helper.rb	2015-03-19 13:48:26.000000000 -0300
@@ -35,14 +35,22 @@
       # naming convention helps to identify translations that include HTML tags so that
       # you know what kind of output to expect when you call translate in a template.
       def translate(key, options = {})
-        options[:default] = wrap_translate_defaults(options[:default]) if options[:default]
+        options = options.dup
+        has_default = options.has_key?(:default)
+        remaining_defaults = Array(options.delete(:default))
 
-        # If the user has specified rescue_format then pass it all through, otherwise use
-        # raise and do the work ourselves
-        options[:raise] ||= ActionView::Base.raise_on_missing_translations
+        if has_default && !remaining_defaults.first.kind_of?(Symbol)
+          options[:default] = remaining_defaults.shift
+        end
 
-        raise_error = options[:raise] || options.key?(:rescue_format)
-        unless raise_error
+        # If the user has explicitly decided to NOT raise errors, pass that option to I18n.
+        # Otherwise, tell I18n to raise an exception, which we rescue further in this method.
+        # Note: `raise_error` refers to us re-raising the error in this method. I18n is forced to raise by default.
+        if options[:raise] == false || (options.key?(:rescue_format) && options[:rescue_format].nil?)
+          raise_error = false
+          options[:raise] = false
+        else
+          raise_error = options[:raise] || options[:rescue_format] || ActionView::Base.raise_on_missing_translations
           options[:raise] = true
         end
 
@@ -60,10 +68,14 @@
           I18n.translate(scope_key_by_partial(key), options)
         end
       rescue I18n::MissingTranslationData => e
-        raise e if raise_error
+        if remaining_defaults.present?
+          translate remaining_defaults.shift, options.merge(default: remaining_defaults)
+        else
+          raise e if raise_error
 
-        keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])
-        content_tag('span', keys.last.to_s.titleize, :class => 'translation_missing', :title => "translation missing: #{keys.join('.')}")
+          keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])
+          content_tag('span', keys.last.to_s.titleize, :class => 'translation_missing', :title => "translation missing: #{keys.join('.')}")
+        end
       end
       alias :t :translate
 
@@ -92,21 +104,6 @@
         def html_safe_translation_key?(key)
           key.to_s =~ /(\b|_|\.)html$/
         end
-
-        def wrap_translate_defaults(defaults)
-          new_defaults = []
-          defaults     = Array(defaults)
-          while key = defaults.shift
-            if key.is_a?(Symbol)
-              new_defaults << lambda { |_, options| translate key, options.merge(:default => defaults) }
-              break
-            else
-              new_defaults << key
-            end
-          end
-
-          new_defaults
-        end
     end
   end
 end
--- rails-4.1.8/actionview/lib/action_view/renderer/partial_renderer.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionview/lib/action_view/renderer/partial_renderer.rb	2015-03-19 13:48:26.000000000 -0300
@@ -332,7 +332,7 @@
       prepend_formats(options[:formats])
 
       if String === partial
-        @object     = options[:object]
+        @object     = options[:object] if options.has_key?(:object)
         @path       = partial
         @collection = collection
       else
@@ -347,7 +347,7 @@
       end
 
       if as = options[:as]
-        raise_invalid_identifier(as) unless as.to_s =~ /\A[a-z_]\w*\z/
+        raise_invalid_option_as(as) unless as.to_s =~ /\A[a-z_]\w*\z/
         as = as.to_sym
       end
 
@@ -466,7 +466,7 @@
 
     def retrieve_template_keys
       keys = @locals.keys
-      keys << @variable         if @object || @collection
+      keys << @variable if defined?(@object) || @collection
       keys << @variable_counter if @collection
       keys
     end
@@ -482,11 +482,19 @@
     end
 
     IDENTIFIER_ERROR_MESSAGE = "The partial name (%s) is not a valid Ruby identifier; " +
-                               "make sure your partial name starts with a lowercase letter or underscore, " +
+                               "make sure your partial name starts with underscore, " +
+                               "and is followed by any combination of letters, numbers and underscores."
+
+    OPTION_AS_ERROR_MESSAGE  = "The value (%s) of the option `as` is not a valid Ruby identifier; " +
+                               "make sure it starts with lowercase letter, " +
                                "and is followed by any combination of letters, numbers and underscores."
 
     def raise_invalid_identifier(path)
       raise ArgumentError.new(IDENTIFIER_ERROR_MESSAGE % (path))
     end
+
+    def raise_invalid_option_as(as)
+      raise ArgumentError.new(OPTION_AS_ERROR_MESSAGE % (as))
+    end
   end
 end
--- rails-4.1.8/activerecord/lib/active_record/associations/association_scope.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/associations/association_scope.rb	2015-03-19 13:48:26.000000000 -0300
@@ -143,11 +143,7 @@
       end
 
       def eval_scope(klass, scope, owner)
-        if scope.is_a?(Relation)
-          scope
-        else
-          klass.unscoped.instance_exec(owner, &scope)
-        end
+        klass.unscoped.instance_exec(owner, &scope)
       end
     end
   end
--- rails-4.1.8/activerecord/lib/active_record/associations/collection_association.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/associations/collection_association.rb	2015-03-19 13:48:26.000000000 -0300
@@ -33,7 +33,13 @@
           reload
         end
 
-        @proxy ||= CollectionProxy.create(klass, self)
+        if owner.new_record?
+          # Cache the proxy separately before the owner has an id
+          # or else a post-save proxy will still lack the id
+          @new_record_proxy ||= CollectionProxy.create(klass, self)
+        else
+          @proxy ||= CollectionProxy.create(klass, self)
+        end
       end
 
       # Implements the writer method, e.g. foo.items= for Foo.has_many :items
@@ -123,6 +129,16 @@
         first_nth_or_last(:last, *args)
       end
 
+      def take(n = nil)
+        if loaded?
+          n ? target.take(n) : target.first
+        else
+          scope.take(n).tap do |record|
+            set_inverse_instance record if record.is_a? ActiveRecord::Base
+          end
+        end
+      end
+
       def build(attributes = {}, &block)
         if attributes.is_a?(Array)
           attributes.collect { |attr| build(attr, &block) }
@@ -560,8 +576,13 @@
           if reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
             assoc = owner.association(reflection.through_reflection.name)
             assoc.reader.any? { |source|
-              target = source.send(reflection.source_reflection.name)
-              target.respond_to?(:include?) ? target.include?(record) : target == record
+              target_association = source.send(reflection.source_reflection.name)
+
+              if target_association.respond_to?(:include?)
+                target_association.include?(record)
+              else
+                target_association == record
+              end
             } || target.include?(record)
           else
             target.include?(record)
--- rails-4.1.8/activerecord/lib/active_record/associations/collection_proxy.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/associations/collection_proxy.rb	2015-03-19 13:48:26.000000000 -0300
@@ -226,6 +226,10 @@
         @association.last(*args)
       end
 
+      def take(n = nil)
+        @association.take(n)
+      end
+
       # Returns a new object of the collection type that has been instantiated
       # with +attributes+ and linked to this object, but have not yet been saved.
       # You can pass an array of attributes hashes, this will return an array
--- rails-4.1.8/activerecord/lib/active_record/associations/preloader/association.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/associations/preloader/association.rb	2015-03-19 13:48:26.000000000 -0300
@@ -154,6 +154,7 @@
             scope.where!(klass.table_name => { reflection.type => model.base_class.sti_name })
           end
 
+          scope.unscope_values = Array(values[:unscope])
           klass.default_scoped.merge(scope)
         end
       end
--- rails-4.1.8/activerecord/lib/active_record/associations/preloader.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/associations/preloader.rb	2015-03-19 13:48:26.000000000 -0300
@@ -169,6 +169,7 @@
       class NullPreloader
         def self.new(klass, owners, reflection, preload_scope); self; end
         def self.run(preloader); end
+        def self.preloaded_records; []; end
       end
 
       def preloader_for(reflection, owners, rhs_klass)
--- rails-4.1.8/activerecord/lib/active_record/associations/through_association.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/associations/through_association.rb	2015-03-19 13:48:26.000000000 -0300
@@ -92,6 +92,17 @@
             raise HasManyThroughNestedAssociationsAreReadonly.new(owner, reflection)
           end
         end
+
+        def build_record(attributes)
+          inverse = source_reflection.inverse_of
+          target = through_association.target
+
+          if inverse && target && !target.is_a?(Array)
+            attributes[inverse.foreign_key] = target.id
+          end
+
+          super(attributes)
+        end
     end
   end
 end
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb	2015-03-19 13:48:26.000000000 -0300
@@ -238,7 +238,7 @@
 
         @checkout_timeout = (spec.config[:checkout_timeout] && spec.config[:checkout_timeout].to_f) || 5
         @dead_connection_timeout = (spec.config[:dead_connection_timeout] && spec.config[:dead_connection_timeout].to_f) || 5
-        @reaper  = Reaper.new self, spec.config[:reaping_frequency]
+        @reaper = Reaper.new(self, (spec.config[:reaping_frequency] && spec.config[:reaping_frequency].to_f))
         @reaper.run
 
         # default max pool size to 5
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb	2015-03-19 13:48:26.000000000 -0300
@@ -394,8 +394,8 @@
       # Adds timestamps (+created_at+ and +updated_at+) columns to the table. See SchemaStatements#add_timestamps
       #
       #  t.timestamps
-      def timestamps
-        @base.add_timestamps(@table_name)
+      def timestamps(options = {})
+        @base.add_timestamps(@table_name, options)
       end
 
       # Changes the column's definition according to the new options.
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb	2015-03-19 13:48:26.000000000 -0300
@@ -722,9 +722,9 @@
       #
       #   add_timestamps(:suppliers)
       #
-      def add_timestamps(table_name)
-        add_column table_name, :created_at, :datetime
-        add_column table_name, :updated_at, :datetime
+      def add_timestamps(table_name, options = {})
+        add_column table_name, :created_at, :datetime, options
+        add_column table_name, :updated_at, :datetime, options
       end
 
       # Removes the timestamp columns (+created_at+ and +updated_at+) from the table definition.
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb	2015-03-19 13:48:26.000000000 -0300
@@ -356,7 +356,12 @@
       protected
 
       def translate_exception_class(e, sql)
-        message = "#{e.class.name}: #{e.message}: #{sql}"
+        begin
+          message = "#{e.class.name}: #{e.message}: #{sql}"
+        rescue Encoding::CompatibilityError
+          message = "#{e.class.name}: #{e.message.force_encoding sql.encoding}: #{sql}"
+        end
+
         @logger.error message if @logger
         exception = translate_exception(e, message)
         exception.set_backtrace e.backtrace
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb	2015-03-19 13:48:26.000000000 -0300
@@ -717,8 +717,8 @@
         "DROP INDEX #{index_name}"
       end
 
-      def add_timestamps_sql(table_name)
-        [add_column_sql(table_name, :created_at, :datetime), add_column_sql(table_name, :updated_at, :datetime)]
+      def add_timestamps_sql(table_name, options = {})
+        [add_column_sql(table_name, :created_at, :datetime, options), add_column_sql(table_name, :updated_at, :datetime, options)]
       end
 
       def remove_timestamps_sql(table_name)
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb	2015-03-19 13:48:26.000000000 -0300
@@ -27,6 +27,9 @@
         class Bytea < Type
           def type_cast(value)
             return if value.nil?
+            # This is a flawed heuristic, but it avoids truncation;
+            # we really shouldn’t be calling this with already-unescaped values
+            return value if value.dup.force_encoding("BINARY") =~ /\x00/
             PGconn.unescape_bytea value
           end
         end
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb	2015-03-19 13:48:26.000000000 -0300
@@ -382,7 +382,10 @@
           pk, seq = pk_and_sequence_for(new_name)
           if seq == "#{table_name}_#{pk}_seq"
             new_seq = "#{new_name}_#{pk}_seq"
+            idx = "#{table_name}_pkey"
+            new_idx = "#{new_name}_pkey"
             execute "ALTER TABLE #{quote_table_name(seq)} RENAME TO #{quote_table_name(new_seq)}"
+            execute "ALTER INDEX #{quote_table_name(idx)} RENAME TO #{quote_table_name(new_idx)}"
           end
 
           rename_table_indexes(table_name, new_name)
--- rails-4.1.8/activerecord/lib/active_record/core.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/core.rb	2015-03-19 13:48:26.000000000 -0300
@@ -85,7 +85,6 @@
       mattr_accessor :dump_schema_after_migration, instance_writer: false
       self.dump_schema_after_migration = true
 
-      # :nodoc:
       mattr_accessor :maintain_test_schema, instance_accessor: false
 
       def self.disable_implicit_join_references=(value)
--- rails-4.1.8/activerecord/lib/active_record/fixtures.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/fixtures.rb	2015-03-19 13:48:26.000000000 -0300
@@ -790,7 +790,7 @@
 
     def find
       if model_class
-        model_class.find(fixture[model_class.primary_key])
+        model_class.unscoped.find(fixture[model_class.primary_key])
       else
         raise FixtureClassNotFound, "No class attached to find."
       end
--- rails-4.1.8/activerecord/lib/active_record/migration.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/migration.rb	2015-03-19 13:48:26.000000000 -0300
@@ -391,7 +391,14 @@
 
       def load_schema_if_pending!
         if ActiveRecord::Migrator.needs_migration?
-          ActiveRecord::Tasks::DatabaseTasks.load_schema_current
+          # Roundrip to Rake to allow plugins to hook into database initialization.
+          FileUtils.cd Rails.root do
+            current_config = Base.connection_config
+            Base.clear_all_connections!
+            system("bin/rake db:test:prepare")
+            # Establish a new connection, the old database may be gone (db:test:prepare uses purge)
+            Base.establish_connection(current_config)
+          end
           check_pending!
         end
       end
--- rails-4.1.8/activerecord/lib/active_record/persistence.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/persistence.rb	2015-03-19 13:48:26.000000000 -0300
@@ -181,7 +181,8 @@
       became = klass.new
       became.instance_variable_set("@attributes", @attributes)
       became.instance_variable_set("@attributes_cache", @attributes_cache)
-      became.instance_variable_set("@changed_attributes", @changed_attributes) if defined?(@changed_attributes)
+      changed_attributes = @changed_attributes if defined?(@changed_attributes)
+      became.instance_variable_set("@changed_attributes", changed_attributes || {})
       became.instance_variable_set("@new_record", new_record?)
       became.instance_variable_set("@destroyed", destroyed?)
       became.instance_variable_set("@errors", errors)
--- rails-4.1.8/activerecord/lib/active_record/railtie.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/railtie.rb	2015-03-19 13:48:26.000000000 -0300
@@ -36,8 +36,6 @@
     config.eager_load_namespaces << ActiveRecord
 
     rake_tasks do
-      require "active_record/base"
-
       namespace :db do
         task :load_config do
           ActiveRecord::Tasks::DatabaseTasks.database_configuration = Rails.application.config.database_configuration
--- rails-4.1.8/activerecord/lib/active_record/railties/databases.rake	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/railties/databases.rake	2015-03-19 13:48:26.000000000 -0300
@@ -234,7 +234,7 @@
     end
 
     desc 'Load a schema.rb file into the database'
-    task :load => [:environment, :load_config] do
+    task :load => [:load_config] do
       ActiveRecord::Tasks::DatabaseTasks.load_schema_current(:ruby, ENV['SCHEMA'])
     end
 
@@ -299,7 +299,7 @@
     end
 
     # desc "Recreate the test database from the current schema"
-    task :load => %w(db:test:deprecated db:test:purge) do
+    task :load => %w(db:test:purge) do
       case ActiveRecord::Base.schema_format
         when :ruby
           db_namespace["test:load_schema"].invoke
@@ -309,7 +309,7 @@
     end
 
     # desc "Recreate the test database from an existent schema.rb file"
-    task :load_schema => %w(db:test:deprecated db:test:purge) do
+    task :load_schema => %w(db:test:purge) do
       begin
         should_reconnect = ActiveRecord::Base.connection_pool.active_connection?
         ActiveRecord::Schema.verbose = false
@@ -322,7 +322,7 @@
     end
 
     # desc "Recreate the test database from an existent structure.sql file"
-    task :load_structure => %w(db:test:deprecated db:test:purge) do
+    task :load_structure => %w(db:test:purge) do
       ActiveRecord::Tasks::DatabaseTasks.load_schema_for ActiveRecord::Base.configurations['test'], :sql, ENV['SCHEMA']
     end
 
@@ -343,12 +343,12 @@
     task :clone_structure => %w(db:test:deprecated db:structure:dump db:test:load_structure)
 
     # desc "Empty the test database"
-    task :purge => %w(db:test:deprecated environment load_config) do
+    task :purge => %w(environment load_config) do
       ActiveRecord::Tasks::DatabaseTasks.purge ActiveRecord::Base.configurations['test']
     end
 
     # desc 'Check for pending migrations and load the test schema'
-    task :prepare => %w(db:test:deprecated environment load_config) do
+    task :prepare => %w(environment load_config) do
       unless ActiveRecord::Base.configurations.blank?
         db_namespace['test:load'].invoke
       end
--- rails-4.1.8/activerecord/lib/active_record/reflection.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/reflection.rb	2015-03-19 13:48:26.000000000 -0300
@@ -432,7 +432,7 @@
         # returns either nil or the inverse association name that it finds.
         def automatic_inverse_of
           if can_find_inverse_of_automatically?(self)
-            inverse_name = ActiveSupport::Inflector.underscore(options[:as] || active_record.name).to_sym
+            inverse_name = ActiveSupport::Inflector.underscore(options[:as] || active_record.name.demodulize).to_sym
 
             begin
               reflection = klass._reflect_on_association(inverse_name)
@@ -609,8 +609,11 @@
           through_scope_chain = through_reflection.scope_chain.map(&:dup)
 
           if options[:source_type]
-            through_scope_chain.first <<
-              through_reflection.klass.where(foreign_type => options[:source_type])
+            type = foreign_type
+            source_type = options[:source_type]
+            through_scope_chain.first << lambda { |object|
+              where(type => source_type)
+            }
           end
 
           # Recursively fill out the rest of the array from the through reflection
--- rails-4.1.8/activerecord/lib/active_record/relation/batches.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/relation/batches.rb	2015-03-19 13:48:26.000000000 -0300
@@ -115,6 +115,7 @@
       end
 
       relation = relation.reorder(batch_order).limit(batch_size)
+      relation.reverse_order_value = false
       records = start ? relation.where(table[primary_key].gteq(start)).to_a : relation.to_a
 
       while records.any?
--- rails-4.1.8/activerecord/lib/active_record/relation/predicate_builder/relation_handler.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/relation/predicate_builder/relation_handler.rb	2015-03-19 13:48:26.000000000 -0300
@@ -6,6 +6,10 @@
           value = value.select(value.klass.arel_table[value.klass.primary_key])
         end
 
+        value = value.dup
+        value.where_values = value.where_values.map do |node|
+          node.dup rescue node
+        end
         attribute.in(value.arel.ast)
       end
     end
--- rails-4.1.8/activerecord/lib/active_record/relation/predicate_builder.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/relation/predicate_builder.rb	2015-03-19 13:48:26.000000000 -0300
@@ -61,6 +61,8 @@
         end
 
         column = reflection.foreign_key
+        primary_key = reflection.association_primary_key(base_class)
+        value = convert_value_to_association_ids(value, primary_key)
       end
 
       queries << build(table[column], value)
@@ -114,12 +116,28 @@
     register_handler(Array, ArrayHandler.new)
 
     private
-      def self.build(attribute, value)
-        handler_for(value).call(attribute, value)
-      end
 
-      def self.handler_for(object)
-        @handlers.detect { |klass, _| klass === object }.last
+    def self.build(attribute, value)
+      handler_for(value).call(attribute, value)
+    end
+    private_class_method :build
+
+    def self.handler_for(object)
+      @handlers.detect { |klass, _| klass === object }.last
+    end
+    private_class_method :handler_for
+
+    def self.convert_value_to_association_ids(value, primary_key)
+      case value
+      when Relation
+        value.select(primary_key)
+      when Array
+        value.map { |v| convert_value_to_association_ids(v, primary_key) }
+      when Base
+        value.read_attribute(primary_key)
+      else
+        value
       end
+    end
   end
 end
--- rails-4.1.8/activerecord/lib/active_record/relation/query_methods.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/relation/query_methods.rb	2015-03-19 13:48:26.000000000 -0300
@@ -677,11 +677,11 @@
     #   end
     #
     def none
-      extending(NullRelation)
+      where("1=0").extending!(NullRelation)
     end
 
     def none! # :nodoc:
-      extending!(NullRelation)
+      where!("1=0").extending!(NullRelation)
     end
 
     # Sets readonly attributes for the returned relation. If value is
@@ -855,12 +855,11 @@
 
       arel.take(connection.sanitize_limit(limit_value)) if limit_value
       arel.skip(offset_value.to_i) if offset_value
-
-      arel.group(*group_values.uniq.reject(&:blank?)) unless group_values.empty?
+      arel.group(*arel_columns(group_values.uniq.reject(&:blank?))) unless group_values.empty?
 
       build_order(arel)
 
-      build_select(arel, select_values.uniq)
+      build_select(arel)
 
       arel.distinct(distinct_value)
       arel.from(build_from) if from_value
@@ -1008,17 +1007,24 @@
       manager
     end
 
-    def build_select(arel, selects)
-      if !selects.empty?
-        expanded_select = selects.map do |field|
-          columns_hash.key?(field.to_s) ? arel_table[field] : field
-        end
-        arel.project(*expanded_select)
+    def build_select(arel)
+      if select_values.any?
+        arel.project(*arel_columns(select_values.uniq))
       else
         arel.project(@klass.arel_table[Arel.star])
       end
     end
 
+    def arel_columns(columns)
+      columns.map do |field|
+        if columns_hash.key?(field.to_s)
+          arel_table[field]
+        else
+          field
+        end
+      end
+    end
+
     def reverse_sql_order(order_query)
       order_query = ["#{quoted_table_name}.#{quoted_primary_key} ASC"] if order_query.empty?
 
--- rails-4.1.8/activerecord/lib/active_record/tasks/database_tasks.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/tasks/database_tasks.rb	2015-03-19 13:48:26.000000000 -0300
@@ -167,13 +167,11 @@
         when :ruby
           file ||= File.join(db_dir, "schema.rb")
           check_schema_file(file)
-          purge(configuration)
           ActiveRecord::Base.establish_connection(configuration)
           load(file)
         when :sql
           file ||= File.join(db_dir, "structure.sql")
           check_schema_file(file)
-          purge(configuration)
           structure_load(configuration, file)
         else
           raise ArgumentError, "unknown format #{format.inspect}"
--- rails-4.1.8/activerecord/lib/active_record/transactions.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/transactions.rb	2015-03-19 13:48:26.000000000 -0300
@@ -249,7 +249,7 @@
 
       def assert_valid_transaction_action(actions)
         if (actions - ACTIONS).any?
-          raise ArgumentError, ":on conditions for after_commit and after_rollback callbacks have to be one of #{ACTIONS.join(",")}"
+          raise ArgumentError, ":on conditions for after_commit and after_rollback callbacks have to be one of #{ACTIONS}"
         end
       end
     end
--- rails-4.1.8/activerecord/lib/active_record/validations/uniqueness.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/validations/uniqueness.rb	2015-03-19 13:48:26.000000000 -0300
@@ -81,7 +81,15 @@
           else
             scope_value = record.read_attribute(scope_item)
           end
-          relation = relation.and(table[scope_item].eq(scope_value))
+
+          # This is basically emulating an Arel::Nodes::Casted
+          column = record.class.columns_hash[scope_item.to_s]
+          quoted_value = record.class.connection.quote(scope_value, column)
+          unless scope_value.nil?
+            node = Arel::Nodes::SqlLiteral.new(quoted_value)
+          end
+
+          relation = relation.and(table[scope_item].eq(node))
         end
 
         relation
--- rails-4.1.8/activesupport/lib/active_support/cache.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/cache.rb	2015-03-19 13:48:26.000000000 -0300
@@ -624,7 +624,7 @@
       # Check if the entry is expired. The +expires_in+ parameter can override
       # the value set when the entry was created.
       def expired?
-        convert_version_4beta1_entry! if defined?(@value)
+        convert_version_4beta1_entry! if defined?(@v)
         @expires_in && @created_at + @expires_in <= Time.now.to_f
       end
 
--- rails-4.1.8/activesupport/lib/active_support/callbacks.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/callbacks.rb	2015-03-19 13:48:26.000000000 -0300
@@ -117,24 +117,24 @@
       ENDING = End.new
 
       class Before
-        def self.build(next_callback, user_callback, user_conditions, chain_config, filter)
+        def self.build(callback_sequence, user_callback, user_conditions, chain_config, filter)
           halted_lambda = chain_config[:terminator]
 
           if chain_config.key?(:terminator) && user_conditions.any?
-            halting_and_conditional(next_callback, user_callback, user_conditions, halted_lambda, filter)
+            halting_and_conditional(callback_sequence, user_callback, user_conditions, halted_lambda, filter)
           elsif chain_config.key? :terminator
-            halting(next_callback, user_callback, halted_lambda, filter)
+            halting(callback_sequence, user_callback, halted_lambda, filter)
           elsif user_conditions.any?
-            conditional(next_callback, user_callback, user_conditions)
+            conditional(callback_sequence, user_callback, user_conditions)
           else
-            simple next_callback, user_callback
+            simple callback_sequence, user_callback
           end
         end
 
         private
 
-        def self.halting_and_conditional(next_callback, user_callback, user_conditions, halted_lambda, filter)
-          lambda { |env|
+        def self.halting_and_conditional(callback_sequence, user_callback, user_conditions, halted_lambda, filter)
+          callback_sequence.before do |env|
             target = env.target
             value  = env.value
             halted = env.halted
@@ -146,12 +146,13 @@
                 target.send :halted_callback_hook, filter
               end
             end
-            next_callback.call env
-          }
+
+            env
+          end
         end
 
-        def self.halting(next_callback, user_callback, halted_lambda, filter)
-          lambda { |env|
+        def self.halting(callback_sequence, user_callback, halted_lambda, filter)
+          callback_sequence.before do |env|
             target = env.target
             value  = env.value
             halted = env.halted
@@ -163,56 +164,58 @@
                 target.send :halted_callback_hook, filter
               end
             end
-            next_callback.call env
-          }
+
+            env
+          end
         end
 
-        def self.conditional(next_callback, user_callback, user_conditions)
-          lambda { |env|
+        def self.conditional(callback_sequence, user_callback, user_conditions)
+          callback_sequence.before do |env|
             target = env.target
             value  = env.value
 
             if user_conditions.all? { |c| c.call(target, value) }
               user_callback.call target, value
             end
-            next_callback.call env
-          }
+
+            env
+          end
         end
 
-        def self.simple(next_callback, user_callback)
-          lambda { |env|
+        def self.simple(callback_sequence, user_callback)
+          callback_sequence.before do |env|
             user_callback.call env.target, env.value
-            next_callback.call env
-          }
+
+            env
+          end
         end
       end
 
       class After
-        def self.build(next_callback, user_callback, user_conditions, chain_config)
+        def self.build(callback_sequence, user_callback, user_conditions, chain_config)
           if chain_config[:skip_after_callbacks_if_terminated]
             if chain_config.key?(:terminator) && user_conditions.any?
-              halting_and_conditional(next_callback, user_callback, user_conditions)
+              halting_and_conditional(callback_sequence, user_callback, user_conditions)
             elsif chain_config.key?(:terminator)
-              halting(next_callback, user_callback)
+              halting(callback_sequence, user_callback)
             elsif user_conditions.any?
-              conditional next_callback, user_callback, user_conditions
+              conditional callback_sequence, user_callback, user_conditions
             else
-              simple next_callback, user_callback
+              simple callback_sequence, user_callback
             end
           else
             if user_conditions.any?
-              conditional next_callback, user_callback, user_conditions
+              conditional callback_sequence, user_callback, user_conditions
             else
-              simple next_callback, user_callback
+              simple callback_sequence, user_callback
             end
           end
         end
 
         private
 
-        def self.halting_and_conditional(next_callback, user_callback, user_conditions)
-          lambda { |env|
-            env = next_callback.call env
+        def self.halting_and_conditional(callback_sequence, user_callback, user_conditions)
+          callback_sequence.after do |env|
             target = env.target
             value  = env.value
             halted = env.halted
@@ -220,117 +223,119 @@
             if !halted && user_conditions.all? { |c| c.call(target, value) }
               user_callback.call target, value
             end
+
             env
-          }
+          end
         end
 
-        def self.halting(next_callback, user_callback)
-          lambda { |env|
-            env = next_callback.call env
+        def self.halting(callback_sequence, user_callback)
+          callback_sequence.after do |env|
             unless env.halted
               user_callback.call env.target, env.value
             end
+
             env
-          }
+          end
         end
 
-        def self.conditional(next_callback, user_callback, user_conditions)
-          lambda { |env|
-            env = next_callback.call env
+        def self.conditional(callback_sequence, user_callback, user_conditions)
+          callback_sequence.after do |env|
             target = env.target
             value  = env.value
 
             if user_conditions.all? { |c| c.call(target, value) }
               user_callback.call target, value
             end
+
             env
-          }
+          end
         end
 
-        def self.simple(next_callback, user_callback)
-          lambda { |env|
-            env = next_callback.call env
+        def self.simple(callback_sequence, user_callback)
+          callback_sequence.after do |env|
             user_callback.call env.target, env.value
+
             env
-          }
+          end
         end
       end
 
       class Around
-        def self.build(next_callback, user_callback, user_conditions, chain_config)
+        def self.build(callback_sequence, user_callback, user_conditions, chain_config)
           if chain_config.key?(:terminator) && user_conditions.any?
-            halting_and_conditional(next_callback, user_callback, user_conditions)
+            halting_and_conditional(callback_sequence, user_callback, user_conditions)
           elsif chain_config.key? :terminator
-            halting(next_callback, user_callback)
+            halting(callback_sequence, user_callback)
           elsif user_conditions.any?
-            conditional(next_callback, user_callback, user_conditions)
+            conditional(callback_sequence, user_callback, user_conditions)
           else
-            simple(next_callback, user_callback)
+            simple(callback_sequence, user_callback)
           end
         end
 
         private
 
-        def self.halting_and_conditional(next_callback, user_callback, user_conditions)
-          lambda { |env|
+        def self.halting_and_conditional(callback_sequence, user_callback, user_conditions)
+          callback_sequence.around do |env, &run|
             target = env.target
             value  = env.value
             halted = env.halted
 
             if !halted && user_conditions.all? { |c| c.call(target, value) }
               user_callback.call(target, value) {
-                env = next_callback.call env
+                env = run.call env
                 env.value
               }
+
               env
             else
-              next_callback.call env
+              run.call env
             end
-          }
+          end
         end
 
-        def self.halting(next_callback, user_callback)
-          lambda { |env|
+        def self.halting(callback_sequence, user_callback)
+          callback_sequence.around do |env, &run|
             target = env.target
             value  = env.value
 
-            unless env.halted
+            if env.halted
+              run.call env
+            else
               user_callback.call(target, value) {
-                env = next_callback.call env
+                env = run.call env
                 env.value
               }
               env
-            else
-              next_callback.call env
             end
-          }
+          end
         end
 
-        def self.conditional(next_callback, user_callback, user_conditions)
-          lambda { |env|
+        def self.conditional(callback_sequence, user_callback, user_conditions)
+          callback_sequence.around do |env, &run|
             target = env.target
             value  = env.value
 
             if user_conditions.all? { |c| c.call(target, value) }
               user_callback.call(target, value) {
-                env = next_callback.call env
+                env = run.call env
                 env.value
               }
               env
             else
-              next_callback.call env
+              run.call env
             end
-          }
+          end
         end
 
-        def self.simple(next_callback, user_callback)
-          lambda { |env|
+        def self.simple(callback_sequence, user_callback)
+          callback_sequence.around do |env, &run|
             user_callback.call(env.target, env.value) {
-              env = next_callback.call env
+              env = run.call env
               env.value
             }
             env
-          }
+          end
         end
       end
     end
@@ -382,17 +387,17 @@
       end
 
       # Wraps code with filter
-      def apply(next_callback)
+      def apply(callback_sequence)
         user_conditions = conditions_lambdas
         user_callback = make_lambda @filter
 
         case kind
         when :before
-          Filters::Before.build(next_callback, user_callback, user_conditions, chain_config, @filter)
+          Filters::Before.build(callback_sequence, user_callback, user_conditions, chain_config, @filter)
         when :after
-          Filters::After.build(next_callback, user_callback, user_conditions, chain_config)
+          Filters::After.build(callback_sequence, user_callback, user_conditions, chain_config)
         when :around
-          Filters::Around.build(next_callback, user_callback, user_conditions, chain_config)
+          Filters::Around.build(callback_sequence, user_callback, user_conditions, chain_config)
         end
       end
 
@@ -464,6 +469,42 @@
       end
     end
 
+    # Execute before and after filters in a sequence instead of
+    # chaining them with nested lambda calls, see:
+    # https://github.com/rails/rails/issues/18011
+    class CallbackSequence
+      def initialize(&call)
+        @call = call
+        @before = []
+        @after = []
+      end
+
+      def before(&before)
+        @before.unshift(before)
+        self
+      end
+
+      def after(&after)
+        @after.push(after)
+        self
+      end
+
+      def around(&around)
+        CallbackSequence.new do |*args|
+          around.call(*args) {
+            self.call(*args)
+          }
+        end
+      end
+
+      def call(*args)
+        @before.each { |b| b.call(*args) }
+        value = @call.call(*args)
+        @after.each { |a| a.call(*args) }
+        value
+      end
+    end
+
     # An Array with a compile method.
     class CallbackChain #:nodoc:#
       include Enumerable
@@ -508,8 +549,9 @@
 
       def compile
         @callbacks || @mutex.synchronize do
-          @callbacks ||= @chain.reverse.inject(Filters::ENDING) do |chain, callback|
-            callback.apply chain
+          final_sequence = CallbackSequence.new { |env| Filters::ENDING.call(env) }
+          @callbacks ||= @chain.reverse.inject(final_sequence) do |callback_sequence, callback|
+            callback.apply callback_sequence
           end
         end
       end
--- rails-4.1.8/activesupport/lib/active_support/core_ext/string/filters.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/core_ext/string/filters.rb	2015-03-19 13:48:26.000000000 -0300
@@ -3,7 +3,7 @@
   # the string, and then changing remaining consecutive whitespace
   # groups into one space each.
   #
-  # Note that it handles both ASCII and Unicode whitespace like mongolian vowel separator (U+180E).
+  # Note that it handles both ASCII and Unicode whitespace.
   #
   #   %{ Multi-line
   #      string }.squish                   # => "Multi-line string"
--- rails-4.1.8/activesupport/lib/active_support/core_ext/string/output_safety.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/core_ext/string/output_safety.rb	2015-03-19 13:48:26.000000000 -0300
@@ -142,7 +142,11 @@
       else
         if html_safe?
           new_safe_buffer = super
-          new_safe_buffer.instance_eval { @html_safe = true }
+
+          if new_safe_buffer
+            new_safe_buffer.instance_eval { @html_safe = true }
+          end
+
           new_safe_buffer
         else
           to_str[*args]
@@ -206,7 +210,7 @@
     end
 
     def encode_with(coder)
-      coder.represent_scalar nil, to_str
+      coder.represent_object nil, to_str
     end
 
     UNSAFE_STRING_METHODS.each do |unsafe_method|
--- rails-4.1.8/activesupport/lib/active_support/core_ext/time/zones.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/core_ext/time/zones.rb	2015-03-19 13:48:26.000000000 -0300
@@ -1,4 +1,5 @@
 require 'active_support/time_with_zone'
+require 'active_support/core_ext/time/acts_like'
 require 'active_support/core_ext/date_and_time/zones'
 
 class Time
--- rails-4.1.8/activesupport/lib/active_support/duration.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/duration.rb	2015-03-19 13:48:26.000000000 -0300
@@ -78,7 +78,7 @@
         reduce(::Hash.new(0)) { |h,(l,r)| h[l] += r; h }.
         sort_by {|unit,  _ | [:years, :months, :days, :minutes, :seconds].index(unit)}.
         map     {|unit, val| "#{val} #{val == 1 ? unit.to_s.chop : unit.to_s}"}.
-        to_sentence(:locale => :en)
+        to_sentence(locale: ::I18n.default_locale)
     end
 
     def as_json(options = nil) #:nodoc:
--- rails-4.1.8/activesupport/lib/active_support/i18n_railtie.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/i18n_railtie.rb	2015-03-19 13:48:26.000000000 -0300
@@ -36,7 +36,11 @@
       # Avoid issues with setting the default_locale by disabling available locales
       # check while configuring.
       enforce_available_locales = app.config.i18n.delete(:enforce_available_locales)
-      enforce_available_locales = I18n.enforce_available_locales unless I18n.enforce_available_locales.nil?
+
+      if enforce_available_locales.nil?
+        enforce_available_locales = I18n.enforce_available_locales
+      end
+
       I18n.enforce_available_locales = false
 
       app.config.i18n.each do |setting, value|
--- rails-4.1.8/activesupport/lib/active_support/multibyte/unicode.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/multibyte/unicode.rb	2015-03-19 13:48:26.000000000 -0300
@@ -42,7 +42,6 @@
         0x0085,                # White_Space # Cc       <control-0085>
         0x00A0,                # White_Space # Zs       NO-BREAK SPACE
         0x1680,                # White_Space # Zs       OGHAM SPACE MARK
-        0x180E,                # White_Space # Zs       MONGOLIAN VOWEL SEPARATOR
         (0x2000..0x200A).to_a, # White_Space # Zs  [11] EN QUAD..HAIR SPACE
         0x2028,                # White_Space # Zl       LINE SEPARATOR
         0x2029,                # White_Space # Zp       PARAGRAPH SEPARATOR
--- rails-4.1.8/activesupport/lib/active_support/values/time_zone.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/values/time_zone.rb	2015-03-19 13:48:26.000000000 -0300
@@ -111,9 +111,11 @@
       "Jerusalem"                    => "Asia/Jerusalem",
       "Harare"                       => "Africa/Harare",
       "Pretoria"                     => "Africa/Johannesburg",
+      "Kaliningrad"                  => "Europe/Kaliningrad",
       "Moscow"                       => "Europe/Moscow",
       "St. Petersburg"               => "Europe/Moscow",
-      "Volgograd"                    => "Europe/Moscow",
+      "Volgograd"                    => "Europe/Volgograd",
+      "Samara"                       => "Europe/Samara",
       "Kuwait"                       => "Asia/Kuwait",
       "Riyadh"                       => "Asia/Riyadh",
       "Nairobi"                      => "Africa/Nairobi",
@@ -170,6 +172,7 @@
       "Guam"                         => "Pacific/Guam",
       "Port Moresby"                 => "Pacific/Port_Moresby",
       "Magadan"                      => "Asia/Magadan",
+      "Srednekolymsk"                => "Asia/Srednekolymsk",
       "Solomon Is."                  => "Pacific/Guadalcanal",
       "New Caledonia"                => "Pacific/Noumea",
       "Fiji"                         => "Pacific/Fiji",
--- rails-4.1.8/debian/changelog	2014-11-25 16:51:56.000000000 -0200
+++ rails-4.1.10/debian/changelog	2015-04-03 18:25:30.000000000 -0300
@@ -1,3 +1,11 @@
+rails (2:4.1.10-1) UNRELEASED; urgency=medium
+
+  * New upstream release; bug fixes only
+  * debian/copyright: fix mention to the license of
+    guides/assets/javascripts/jquery.min.js
+
+ -- Antonio Terceiro <terceiro@debian.org>  Fri, 03 Apr 2015 18:19:36 -0300
+
 rails (2:4.1.8-1) unstable; urgency=medium
 
   * New upstream release
--- rails-4.1.8/debian/copyright	2014-11-25 16:51:56.000000000 -0200
+++ rails-4.1.10/debian/copyright	2015-04-03 18:25:30.000000000 -0300
@@ -11,6 +11,11 @@
 Copyright: Copyright 2004-2013 David Heinemeier Hansson
 License: CC-BY-3.0
 
+Files: guides/assets/javascripts/jquery.min.js
+Copyright: Copyright 2011, John Resig
+ Copyright 2011, The Dojo Foundation
+License: Expat or BSD or GPL
+
 Files: guides/assets/javascripts/syntaxhighlighter/*.js
        guides/assets/stylesheets/syntaxhighlighter/*.css
 Copyright: 2004-2010 Alex Gorbatchev
@@ -400,3 +405,30 @@
      not granted under this License, such additional rights are deemed
      to be included in the License; this License is not intended to
      restrict the license of any rights under applicable law.
+
+License: BSD
+ All rights reserved.
+ .
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the University nor the names of its contributors
+    may be used to endorse or promote products derived from this software
+    without specific prior written permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
--- rails-4.1.8/.gitignore	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/.gitignore	2015-03-19 13:48:26.000000000 -0300
@@ -5,7 +5,6 @@
 .Gemfile
 /.bundle
 /.ruby-version
-/Gemfile.lock
 pkg
 /dist
 /doc/rdoc
--- rails-4.1.8/guides/bug_report_templates/action_controller_gem.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/guides/bug_report_templates/action_controller_gem.rb	2015-03-19 13:48:26.000000000 -0300
@@ -7,8 +7,8 @@
 class TestApp < Rails::Application
   config.root = File.dirname(__FILE__)
   config.session_store :cookie_store, key: 'cookie_store_key'
-  config.secret_token    = 'secret_token'
-  config.secret_key_base = 'secret_key_base'
+  secrets.secret_token    = 'secret_token'
+  secrets.secret_key_base = 'secret_key_base'
 
   config.logger = Logger.new($stdout)
   Rails.logger  = config.logger
--- rails-4.1.8/guides/bug_report_templates/action_controller_master.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/guides/bug_report_templates/action_controller_master.rb	2015-03-19 13:48:26.000000000 -0300
@@ -16,8 +16,8 @@
 class TestApp < Rails::Application
   config.root = File.dirname(__FILE__)
   config.session_store :cookie_store, key: 'cookie_store_key'
-  config.secret_token    = 'secret_token'
-  config.secret_key_base = 'secret_key_base'
+  secrets.secret_token    = 'secret_token'
+  secrets.secret_key_base = 'secret_key_base'
 
   config.logger = Logger.new($stdout)
   Rails.logger  = config.logger
--- rails-4.1.8/RAILS_VERSION	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/RAILS_VERSION	2015-03-19 13:48:26.000000000 -0300
@@ -1 +1 @@
-4.1.8
+4.1.10
--- rails-4.1.8/railties/lib/rails/application.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/application.rb	2015-03-19 13:48:26.000000000 -0300
@@ -158,7 +158,7 @@
           key_generator = ActiveSupport::KeyGenerator.new(secrets.secret_key_base, iterations: 1000)
           ActiveSupport::CachingKeyGenerator.new(key_generator)
         else
-          ActiveSupport::LegacyKeyGenerator.new(config.secret_token)
+          ActiveSupport::LegacyKeyGenerator.new(secrets.secret_token)
         end
       end
     end
@@ -197,7 +197,7 @@
         super.merge({
           "action_dispatch.parameter_filter" => config.filter_parameters,
           "action_dispatch.redirect_filter" => config.filter_redirect,
-          "action_dispatch.secret_token" => config.secret_token,
+          "action_dispatch.secret_token" => secrets.secret_token,
           "action_dispatch.secret_key_base" => secrets.secret_key_base,
           "action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions,
           "action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local,
@@ -316,7 +316,21 @@
       @config = configuration
     end
 
-    def secrets #:nodoc:
+    # Returns secrets added to config/secrets.yml.
+    #
+    # Example:
+    #
+    #     development:
+    #       secret_key_base: 836fa3665997a860728bcb9e9a1e704d427cfc920e79d847d79c8a9a907b9e965defa4154b2b86bdec6930adbe33f21364523a6f6ce363865724549fdfc08553
+    #     test:
+    #       secret_key_base: 5a37811464e7d378488b0f073e2193b093682e4e21f5d6f3ae0a4e1781e61a351fdc878a843424e81c73fb484a40d23f92c8dafac4870e74ede6e5e174423010
+    #     production:
+    #       secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
+    #       namespace: my_app_production
+    #
+    # +Rails.application.secrets.namespace+ returns +my_app_production+ in the
+    # production environment.
+    def secrets
       @secrets ||= begin
         secrets = ActiveSupport::OrderedOptions.new
         yaml = config.paths["config/secrets"].first
@@ -329,6 +343,8 @@
 
         # Fallback to config.secret_key_base if secrets.secret_key_base isn't set
         secrets.secret_key_base ||= config.secret_key_base
+        # Fallback to config.secret_token if secrets.secret_token isn't set
+        secrets.secret_token ||= config.secret_token
 
         secrets
       end
@@ -458,8 +474,13 @@
     end
 
     def validate_secret_key_config! #:nodoc:
-      if secrets.secret_key_base.blank? && config.secret_token.blank?
-        raise "Missing `secret_key_base` for '#{Rails.env}' environment, set this value in `config/secrets.yml`"
+      if secrets.secret_key_base.blank?
+        ActiveSupport::Deprecation.warn "You didn't set `secret_key_base`. " +
+          "Read the upgrade documentation to learn more about this new config option."
+
+        if secrets.secret_token.blank?
+          raise "Missing `secret_token` and `secret_key_base` for '#{Rails.env}' environment, set these values in `config/secrets.yml`"
+        end
       end
     end
   end
--- rails-4.1.8/railties/lib/rails/engine.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/engine.rb	2015-03-19 13:48:26.000000000 -0300
@@ -351,7 +351,7 @@
 
           base.called_from = begin
             call_stack = if Kernel.respond_to?(:caller_locations)
-              caller_locations.map(&:path)
+              caller_locations.map { |l| l.absolute_path || l.path }
             else
               # Remove the line number from backtraces making sure we don't leave anything behind
               caller.map { |p| p.sub(/:\d+.*/, '') }
@@ -567,10 +567,10 @@
     end
 
     initializer :add_routing_paths do |app|
-      paths = self.paths["config/routes.rb"].existent
+      routing_paths = self.paths["config/routes.rb"].existent
 
-      if routes? || paths.any?
-        app.routes_reloader.paths.unshift(*paths)
+      if routes? || routing_paths.any?
+        app.routes_reloader.paths.unshift(*routing_paths)
         app.routes_reloader.route_sets << routes
       end
     end
--- rails-4.1.8/railties/lib/rails/generators/actions.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/actions.rb	2015-03-19 13:48:26.000000000 -0300
@@ -218,10 +218,10 @@
       #   route "root 'welcome#index'"
       def route(routing_code)
         log :route, routing_code
-        sentinel = /\.routes\.draw do\s*$/
+        sentinel = /\.routes\.draw do\s*\n/m
 
         in_root do
-          inject_into_file 'config/routes.rb', "\n  #{routing_code}", { after: sentinel, verbose: false }
+          inject_into_file 'config/routes.rb', "  #{routing_code}\n", { after: sentinel, verbose: false, force: true }
         end
       end
 
--- rails-4.1.8/railties/lib/rails/generators/app_base.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/app_base.rb	2015-03-19 13:48:26.000000000 -0300
@@ -241,23 +241,14 @@
       def assets_gemfile_entry
         return [] if options[:skip_sprockets]
 
-        gems = []
-        if options.dev? || options.edge?
-          gems << GemfileEntry.github('sprockets-rails', 'rails/sprockets-rails', '2-1-stable',
-                                    'Use latest 2.1 version of sprockets-rails')
-          gems << GemfileEntry.github('sass-rails', 'rails/sass-rails', nil,
-                                    'Use SCSS for stylesheets')
-        else
-          gems << GemfileEntry.version('sass-rails',
-                                     '~> 4.0.3',
-                                     'Use SCSS for stylesheets')
-        end
-
-        gems << GemfileEntry.version('uglifier',
-                                   '>= 1.3.0',
-                                   'Use Uglifier as compressor for JavaScript assets')
-
-        gems
+        [
+          GemfileEntry.version('sass-rails',
+                               '~> 4.0.3',
+                               'Use SCSS for stylesheets'),
+          GemfileEntry.version('uglifier',
+                               '>= 1.3.0',
+                               'Use Uglifier as compressor for JavaScript assets')
+        ]
       end
 
       def jbuilder_gemfile_entry
@@ -294,7 +285,7 @@
       end
 
       def javascript_runtime_gemfile_entry
-        comment = 'See https://github.com/sstephenson/execjs#readme for more supported runtimes'
+        comment = 'See https://github.com/rails/execjs#readme for more supported runtimes'
         if defined?(JRUBY_VERSION)
           GemfileEntry.version 'therubyrhino', nil, comment
         else
--- rails-4.1.8/railties/lib/rails/generators/rails/app/app_generator.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/rails/app/app_generator.rb	2015-03-19 13:48:26.000000000 -0300
@@ -334,7 +334,7 @@
     #
     # This class should be called before the AppGenerator is required and started
     # since it configures and mutates ARGV correctly.
-    class ARGVScrubber # :nodoc
+    class ARGVScrubber # :nodoc:
       def initialize(argv = ARGV)
         @argv = argv
       end
--- rails-4.1.8/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt	2015-03-19 13:48:26.000000000 -0300
@@ -7,7 +7,7 @@
 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
 // compiled file.
 //
-// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
+// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
 // about supported directives.
 //
 <% unless options[:skip_javascript] -%>
--- rails-4.1.8/railties/lib/rails/generators/rails/app/templates/config/application.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/rails/app/templates/config/application.rb	2015-03-19 13:48:26.000000000 -0300
@@ -3,6 +3,7 @@
 <% if include_all_railties? -%>
 require 'rails/all'
 <% else -%>
+require "rails"
 # Pick the frameworks you want:
 require "active_model/railtie"
 <%= comment_if :skip_active_record %>require "active_record/railtie"
--- rails-4.1.8/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js	2015-03-19 13:48:26.000000000 -0300
@@ -7,7 +7,7 @@
 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
 // compiled file.
 //
-// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
+// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
 // about supported directives.
 //
 //= require_tree .
--- rails-4.1.8/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb	2015-03-19 13:48:26.000000000 -0300
@@ -29,8 +29,10 @@
           write("end", route_length - index)
         end
 
-        # route prepends two spaces onto the front of the string that is passed, this corrects that
-        route route_string[2..-1]
+        # route prepends two spaces onto the front of the string that is passed, this corrects that.
+        # Also it adds a \n to the end of each line, as route already adds that
+        # we need to correct that too.
+        route route_string[2..-2]
       end
 
       private
--- rails-4.1.8/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb	2015-03-19 13:48:26.000000000 -0300
@@ -7,6 +7,7 @@
 
       check_class_collision suffix: "Controller"
 
+      class_option :helper, type: :boolean
       class_option :orm, banner: "NAME", type: :string, required: true,
                          desc: "ORM to generate the controller for"
 
--- rails-4.1.8/tasks/release.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/tasks/release.rb	2015-03-19 13:48:26.000000000 -0300
@@ -102,7 +102,7 @@
       abort "[ABORTING] `git status` reports a dirty tree. Make sure all changes are committed"
     end
 
-    unless ENV['SKIP_TAG'] || `git tag | grep '^#{tag}$`.strip.empty?
+    unless ENV['SKIP_TAG'] || `git tag | grep '^#{tag}$'`.strip.empty?
       abort "[ABORTING] `git tag` shows that #{tag} already exists. Has this version already\n"\
             "           been released? Git tagging can be skipped by setting SKIP_TAG=1"
     end
diff -Nru rails-4.1.8/actionmailer/CHANGELOG.md rails-4.1.10/actionmailer/CHANGELOG.md
--- rails-4.1.8/actionmailer/CHANGELOG.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionmailer/CHANGELOG.md	2015-03-19 13:48:26.000000000 -0300
@@ -1,9 +1,31 @@
+## Rails 4.1.10 (March 19, 2015) ##
+
+*   No changes.
+
+
+## Rails 4.1.9 (January 6, 2015) ##
+
+*   No changes.
+
+
+## Rails 4.1.8 (November 16, 2014) ##
+
 *   Attachments can be added while rendering the mail template.
 
     Fixes #16974.
 
     *Christian Felder*
 
+## Rails 4.1.7.1 (November 19, 2014) ##
+
+*   No changes.
+
+
+## Rails 4.1.7 (October 29, 2014) ##
+
+*   No changes.
+
+
 ## Rails 4.1.6 (September 11, 2014) ##
 
 *   Make ActionMailer::Previews methods class methods. Previously they were
diff -Nru rails-4.1.8/actionmailer/lib/action_mailer/gem_version.rb rails-4.1.10/actionmailer/lib/action_mailer/gem_version.rb
--- rails-4.1.8/actionmailer/lib/action_mailer/gem_version.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionmailer/lib/action_mailer/gem_version.rb	2015-03-19 13:48:26.000000000 -0300
@@ -7,7 +7,7 @@
   module VERSION
     MAJOR = 4
     MINOR = 1
-    TINY  = 8
+    TINY  = 10
     PRE   = nil
 
     STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
diff -Nru rails-4.1.8/actionpack/CHANGELOG.md rails-4.1.10/actionpack/CHANGELOG.md
--- rails-4.1.8/actionpack/CHANGELOG.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/CHANGELOG.md	2015-03-19 13:48:26.000000000 -0300
@@ -1,3 +1,50 @@
+## Rails 4.1.10 (March 19, 2015) ##
+
+*   Preserve default format when generating URLs
+
+    Fixes an issue that would cause the format set in default_url_options to be
+    lost when generating URLs with fewer positional arguments than parameters in
+    the route definition.
+
+    Backport of #18627
+
+    *Tekin Suleyman*, *Dominic Baggott*
+
+*   Default headers, removed in controller actions, are no longer reapplied on
+    the test response.
+
+    *Jonas Baumann*
+
+*   Ensure `append_info_to_payload` is called even if an exception is raised.
+
+    Fixes an issue where when an exception is raised in the request the additonal
+    payload data is not available.
+
+    See:
+    * #14903
+    * https://github.com/roidrage/lograge/issues/37
+
+    *Dieter Komendera*, *Margus Pärt*
+
+
+## Rails 4.1.9 (January 6, 2015) ##
+
+*   Fixed handling of positional url helper arguments when `format: false`.
+
+    Fixes #17819.
+
+    *Andrew White*, *Tatiana Soukiassian*
+
+*   Restore handling of a bare `Authorization` header, without `token=`
+    prefix.
+
+    Fixes #17108.
+
+    *Guo Xiang Tan*
+
+
+## Rails 4.1.8 (November 16, 2014) ##
+
 *   Fix regression where path was getting overwritten when route anchor was false, and X-Cascade pass
 
     fixes #17035.
@@ -11,6 +58,20 @@
     *Yuki Nishijima*
 
 
+## Rails 4.1.7.1 (November 19, 2014) ##
+
+*   Fix arbitrary file existence disclosure in Action Pack.
+
+    CVE-2014-7829.
+
+
+## Rails 4.1.7 (October 29, 2014) ##
+
+*   Fix arbitrary file existence disclosure in Action Pack.
+
+    CVE-2014-7818.
+
+
 ## Rails 4.1.6 (September 11, 2014) ##
 
 *   Prepend a JS comment to JSONP callbacks. Addresses CVE-2014-4671
diff -Nru rails-4.1.8/actionpack/lib/action_controller/base.rb rails-4.1.10/actionpack/lib/action_controller/base.rb
--- rails-4.1.8/actionpack/lib/action_controller/base.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_controller/base.rb	2015-03-19 13:48:26.000000000 -0300
@@ -44,7 +44,7 @@
   # The full request object is available via the request accessor and is primarily used to query for HTTP headers:
   #
   #   def server_ip
-  #     location = request.env["SERVER_ADDR"]
+  #     location = request.env["REMOTE_ADDR"]
   #     render plain: "This server hosted at #{location}"
   #   end
   #
diff -Nru rails-4.1.8/actionpack/lib/action_controller/metal/http_authentication.rb rails-4.1.10/actionpack/lib/action_controller/metal/http_authentication.rb
--- rails-4.1.8/actionpack/lib/action_controller/metal/http_authentication.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_controller/metal/http_authentication.rb	2015-03-19 13:48:26.000000000 -0300
@@ -397,6 +397,7 @@
     #
     #   RewriteRule ^(.*)$ dispatch.fcgi [E=X-HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L]
     module Token
+      TOKEN_KEY = 'token='
       TOKEN_REGEX = /^Token /
       AUTHN_PAIR_DELIMITERS = /(?:,|;|\t+)/
       extend self
@@ -471,7 +472,13 @@
       # pairs by the standardized `:`, `;`, or `\t` delimiters defined in
       # `AUTHN_PAIR_DELIMITERS`.
       def raw_params(auth)
-        auth.sub(TOKEN_REGEX, '').split(/"\s*#{AUTHN_PAIR_DELIMITERS}\s*/)
+        _raw_params = auth.sub(TOKEN_REGEX, '').split(/\s*#{AUTHN_PAIR_DELIMITERS}\s*/)
+
+        if !(_raw_params.first =~ %r{\A#{TOKEN_KEY}})
+          _raw_params[0] = "#{TOKEN_KEY}#{_raw_params.first}"
+        end
+
+        _raw_params
       end
 
       # Encodes the given token and options into an Authorization header value.
@@ -481,7 +488,7 @@
       #
       # Returns String.
       def encode_credentials(token, options = {})
-        values = ["token=#{token.to_s.inspect}"] + options.map do |key, value|
+        values = ["#{TOKEN_KEY}#{token.to_s.inspect}"] + options.map do |key, value|
           "#{key}=#{value.to_s.inspect}"
         end
         "Token #{values * ", "}"
diff -Nru rails-4.1.8/actionpack/lib/action_controller/metal/instrumentation.rb rails-4.1.10/actionpack/lib/action_controller/metal/instrumentation.rb
--- rails-4.1.8/actionpack/lib/action_controller/metal/instrumentation.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_controller/metal/instrumentation.rb	2015-03-19 13:48:26.000000000 -0300
@@ -28,10 +28,13 @@
       ActiveSupport::Notifications.instrument("start_processing.action_controller", raw_payload.dup)
 
       ActiveSupport::Notifications.instrument("process_action.action_controller", raw_payload) do |payload|
-        result = super
-        payload[:status] = response.status
-        append_info_to_payload(payload)
-        result
+        begin
+          result = super
+          payload[:status] = response.status
+          result
+        ensure
+          append_info_to_payload(payload)
+        end
       end
     end
 
diff -Nru rails-4.1.8/actionpack/lib/action_dispatch/http/mime_negotiation.rb rails-4.1.10/actionpack/lib/action_dispatch/http/mime_negotiation.rb
--- rails-4.1.8/actionpack/lib/action_dispatch/http/mime_negotiation.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_dispatch/http/mime_negotiation.rb	2015-03-19 13:48:26.000000000 -0300
@@ -70,7 +70,7 @@
       def variant=(variant)
         if variant.is_a?(Symbol)
           @variant = [variant]
-        elsif variant.is_a?(Array) && variant.any? && variant.all?{ |v| v.is_a?(Symbol) }
+        elsif variant.nil? || variant.is_a?(Array) && variant.any? && variant.all?{ |v| v.is_a?(Symbol) }
           @variant = variant
         else
           raise ArgumentError, "request.variant must be set to a Symbol or an Array of Symbols, not a #{variant.class}. " \
diff -Nru rails-4.1.8/actionpack/lib/action_dispatch/http/parameter_filter.rb rails-4.1.10/actionpack/lib/action_dispatch/http/parameter_filter.rb
--- rails-4.1.8/actionpack/lib/action_dispatch/http/parameter_filter.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_dispatch/http/parameter_filter.rb	2015-03-19 13:48:26.000000000 -0300
@@ -56,7 +56,7 @@
             elsif value.is_a?(Array)
               value = value.map { |v| v.is_a?(Hash) ? call(v) : v }
             elsif blocks.any?
-              key = key.dup
+              key = key.dup if key.duplicable?
               value = value.dup if value.duplicable?
               blocks.each { |b| b.call(key, value) }
             end
diff -Nru rails-4.1.8/actionpack/lib/action_dispatch/middleware/cookies.rb rails-4.1.10/actionpack/lib/action_dispatch/middleware/cookies.rb
--- rails-4.1.8/actionpack/lib/action_dispatch/middleware/cookies.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_dispatch/middleware/cookies.rb	2015-03-19 13:48:26.000000000 -0300
@@ -70,11 +70,13 @@
   #   restrict to the domain level. If you use a schema like www.example.com
   #   and want to share session with user.example.com set <tt>:domain</tt>
   #   to <tt>:all</tt>. Make sure to specify the <tt>:domain</tt> option with
-  #   <tt>:all</tt> again when deleting cookies.
+  #   <tt>:all</tt> or <tt>Array</tt> again when deleting cookies.
   #
   #     domain: nil  # Does not sets cookie domain. (default)
   #     domain: :all # Allow the cookie for the top most level
   #                       domain and subdomains.
+  #     domain: %w(.example.com .example.org) # Allow the cookie 
+  #                       for concrete domain names.
   #
   # * <tt>:expires</tt> - The time at which this cookie expires, as a \Time object.
   # * <tt>:secure</tt> - Whether this cookie is only transmitted to HTTPS servers.
@@ -118,7 +120,7 @@
       # the cookie again. This is useful for creating cookies with values that the user is not supposed to change. If a signed
       # cookie was tampered with by the user (or a 3rd party), nil will be returned.
       #
-      # If +secrets.secret_key_base+ and +config.secret_token+ (deprecated) are both set,
+      # If +secrets.secret_key_base+ and +secrets.secret_token+ (deprecated) are both set,
       # legacy cookies signed with the old key generator will be transparently upgraded.
       #
       # This jar requires that you set a suitable secret for the verification on your app's +secrets.secret_key_base+.
@@ -141,7 +143,7 @@
       # Returns a jar that'll automatically encrypt cookie values before sending them to the client and will decrypt them for read.
       # If the cookie was tampered with by the user (or a 3rd party), nil will be returned.
       #
-      # If +secrets.secret_key_base+ and +config.secret_token+ (deprecated) are both set,
+      # If +secrets.secret_key_base+ and +secrets.secret_token+ (deprecated) are both set,
       # legacy cookies signed with the old key generator will be transparently upgraded.
       #
       # This jar requires that you set a suitable secret for the verification on your app's +secrets.secret_key_base+.
@@ -481,7 +483,7 @@
     end
 
     # UpgradeLegacySignedCookieJar is used instead of SignedCookieJar if
-    # config.secret_token and secrets.secret_key_base are both set. It reads
+    # secrets.secret_token and secrets.secret_key_base are both set. It reads
     # legacy cookies signed with the old dummy key generator and re-saves
     # them using the new key generator to provide a smooth upgrade path.
     class UpgradeLegacySignedCookieJar < SignedCookieJar #:nodoc:
@@ -539,7 +541,7 @@
     end
 
     # UpgradeLegacyEncryptedCookieJar is used by ActionDispatch::Session::CookieStore
-    # instead of EncryptedCookieJar if config.secret_token and secrets.secret_key_base
+    # instead of EncryptedCookieJar if secrets.secret_token and secrets.secret_key_base
     # are both set. It reads legacy cookies signed with the old dummy key generator and
     # encrypts and re-saves them using the new key generator to provide a smooth upgrade path.
     class UpgradeLegacyEncryptedCookieJar < EncryptedCookieJar #:nodoc:
diff -Nru rails-4.1.8/actionpack/lib/action_dispatch/middleware/flash.rb rails-4.1.10/actionpack/lib/action_dispatch/middleware/flash.rb
--- rails-4.1.8/actionpack/lib/action_dispatch/middleware/flash.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_dispatch/middleware/flash.rb	2015-03-19 13:48:26.000000000 -0300
@@ -129,7 +129,7 @@
       end
 
       def key?(name)
-        @flashes.key? name
+        @flashes.key? name.to_s
       end
 
       def delete(key)
diff -Nru rails-4.1.8/actionpack/lib/action_dispatch/routing/route_set.rb rails-4.1.10/actionpack/lib/action_dispatch/routing/route_set.rb
--- rails-4.1.8/actionpack/lib/action_dispatch/routing/route_set.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_dispatch/routing/route_set.rb	2015-03-19 13:48:26.000000000 -0300
@@ -235,12 +235,26 @@
             result = options.dup
 
             if args.size > 0
-              if args.size < keys.size - 1 # take format into account
+              # take format into account
+              if keys.include?(:format)
+                keys_size = keys.size - 1
+              else
+                keys_size = keys.size
+              end
+
+              if args.size < keys_size
                 keys -= t.url_options.keys if t.respond_to?(:url_options)
                 keys -= options.keys
               end
               keys -= inner_options.keys
-              result.merge!(Hash[keys.zip(args)])
+
+              keys.each do |key|
+                value = inner_options.fetch(key) { args.shift }
+
+                unless key == :format && value.nil?
+                  result[key] = value
+                end
+              end
             end
 
             result.merge!(inner_options)
diff -Nru rails-4.1.8/actionpack/lib/action_dispatch/testing/test_response.rb rails-4.1.10/actionpack/lib/action_dispatch/testing/test_response.rb
--- rails-4.1.8/actionpack/lib/action_dispatch/testing/test_response.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_dispatch/testing/test_response.rb	2015-03-19 13:48:26.000000000 -0300
@@ -25,5 +25,12 @@
 
     # Was there a server-side error?
     alias_method :error?, :server_error?
+
+    def merge_default_headers(original, *args)
+      # Default headers are already applied, no need to merge them a second time.
+      # This makes sure that default headers, removed in controller actions, will
+      # not be reapplied to the test response.
+      original
+    end
   end
 end
diff -Nru rails-4.1.8/actionpack/lib/action_pack/gem_version.rb rails-4.1.10/actionpack/lib/action_pack/gem_version.rb
--- rails-4.1.8/actionpack/lib/action_pack/gem_version.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/lib/action_pack/gem_version.rb	2015-03-19 13:48:26.000000000 -0300
@@ -7,7 +7,7 @@
   module VERSION
     MAJOR = 4
     MINOR = 1
-    TINY  = 8
+    TINY  = 10
     PRE   = nil
 
     STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
diff -Nru rails-4.1.8/actionpack/test/controller/base_test.rb rails-4.1.10/actionpack/test/controller/base_test.rb
--- rails-4.1.8/actionpack/test/controller/base_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/test/controller/base_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -51,6 +51,22 @@
   end
 end
 
+class OptionalDefaultUrlOptionsController < ActionController::Base
+  def default_url_options
+    { thing: 'default_thing' }
+  end
+end
+
+class DefaultFormatController < ActionController::Base
+  def show
+    render nothing: true
+  end
+
+  def default_url_options
+    { format: 'atom' }
+  end
+end
+
 class UrlOptionsController < ActionController::Base
   def from_view
     render :inline => "<%= #{params[:route]} %>"
@@ -274,6 +290,30 @@
 
 end
 
+class DefaultFormatControllerTest < ActionController::TestCase
+  def test_default_format_preserved_when_missing_from_positional_arguments
+    with_routing do |set|
+      set.draw do
+        get "/things/:id(.:format)" => 'default_format#show', :as => :thing
+      end
+      assert_equal '/things/1.atom', thing_path("1")
+    end
+  end
+end
+
+class OptionalDefaultUrlOptionsControllerTest < ActionController::TestCase
+  def test_optional_default_url_options_are_overridden_by_missing_positional_args
+    with_routing do |set|
+      set.draw do
+        get "/:category(/:thing)" => "optional_default_url_options#show", :as => :thing
+      end
+
+      assert_equal "/things/a_thing", thing_path('things', 'a_thing')
+      assert_equal "/things/default_thing", thing_path('things')
+    end
+  end
+end
+
 class EmptyUrlOptionsTest < ActionController::TestCase
   tests NonEmptyController
 
diff -Nru rails-4.1.8/actionpack/test/controller/flash_hash_test.rb rails-4.1.10/actionpack/test/controller/flash_hash_test.rb
--- rails-4.1.8/actionpack/test/controller/flash_hash_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/test/controller/flash_hash_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -29,6 +29,15 @@
       assert_equal 'world', @hash['hello']
     end
 
+    def test_key
+      @hash['foo'] = 'bar'
+
+      assert @hash.key?('foo')
+      assert @hash.key?(:foo)
+      assert_not @hash.key?('bar')
+      assert_not @hash.key?(:bar)
+    end
+
     def test_delete
       @hash['foo'] = 'bar'
       @hash.delete 'foo'
diff -Nru rails-4.1.8/actionpack/test/controller/http_token_authentication_test.rb rails-4.1.10/actionpack/test/controller/http_token_authentication_test.rb
--- rails-4.1.8/actionpack/test/controller/http_token_authentication_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/test/controller/http_token_authentication_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -139,20 +139,59 @@
     assert_equal(expected, actual)
   end
 
+  test "token_and_options returns correct token with nounce option" do
+    token = "rcHu+HzSFw89Ypyhn/896A="
+    nonce_hash = {nonce: "123abc"}
+    actual = ActionController::HttpAuthentication::Token.token_and_options(sample_request(token, nonce_hash))
+    expected_token = token
+    expected_nonce = {"nonce" => nonce_hash[:nonce]}
+    assert_equal(expected_token, actual.first)
+    assert_equal(expected_nonce, actual.last)
+  end
+
   test "token_and_options returns nil with no value after the equal sign" do
     actual = ActionController::HttpAuthentication::Token.token_and_options(malformed_request).first
     expected = nil
     assert_equal(expected, actual)
   end
 
+  test "raw_params returns a tuple of two key value pair strings" do
+    auth = sample_request("rcHu+HzSFw89Ypyhn/896A=").authorization.to_s
+    actual = ActionController::HttpAuthentication::Token.raw_params(auth)
+    expected = ["token=\"rcHu+HzSFw89Ypyhn/896A=\"", "nonce=\"def\""]
+    assert_equal(expected, actual)
+  end
+
+  test "token_and_options returns right token when token key is not specified in header" do
+    token = "rcHu+HzSFw89Ypyhn/896A="
+
+    actual = ActionController::HttpAuthentication::Token.token_and_options(
+      sample_request_without_token_key(token)
+    ).first
+
+    expected = token
+    assert_equal(expected, actual)
+  end
+
   private
 
-    def sample_request(token)
-      @sample_request ||= OpenStruct.new authorization: %{Token token="#{token}", nonce="def"}
+    def sample_request(token, options = {nonce: "def"})
+      authorization = options.inject([%{Token token="#{token}"}]) do |arr, (k, v)|
+        arr << "#{k}=\"#{v}\""
+      end.join(", ")
+      mock_authorization_request(authorization)
     end
 
     def malformed_request
-      @malformed_request ||= OpenStruct.new authorization: %{Token token=}
+      mock_authorization_request(%{Token token=})
+    end
+
+    def sample_request_without_token_key(token)
+      mock_authorization_request(%{Token #{token}})
+    end
+
+    def mock_authorization_request(authorization)
+      OpenStruct.new(authorization: authorization)
     end
 
     def encode_credentials(token, options = {})
diff -Nru rails-4.1.8/actionpack/test/controller/integration_test.rb rails-4.1.10/actionpack/test/controller/integration_test.rb
--- rails-4.1.8/actionpack/test/controller/integration_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/test/controller/integration_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -279,6 +279,11 @@
     def redirect
       redirect_to action_url('get')
     end
+
+    def remove_default_header
+      response.headers.except! 'X-Frame-Options'
+      head :ok
+    end
   end
 
   def test_get
@@ -506,6 +511,24 @@
     end
   end
 
+  def test_removed_default_headers_on_test_response_are_not_reapplied
+    with_test_route_set do
+      begin
+        header_to_remove = 'X-Frame-Options'
+        original_default_headers = ActionDispatch::Response.default_headers
+        ActionDispatch::Response.default_headers = {
+          'X-Content-Type-Options' => 'nosniff',
+          header_to_remove => 'SAMEORIGIN',
+        }
+        get '/remove_default_header'
+        assert_includes headers, 'X-Content-Type-Options'
+        assert_not_includes headers, header_to_remove, "Should not contain removed default header"
+      ensure
+        ActionDispatch::Response.default_headers = original_default_headers
+      end
+    end
+  end
+
   private
     def with_test_route_set
       with_routing do |set|
diff -Nru rails-4.1.8/actionpack/test/controller/log_subscriber_test.rb rails-4.1.10/actionpack/test/controller/log_subscriber_test.rb
--- rails-4.1.8/actionpack/test/controller/log_subscriber_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/test/controller/log_subscriber_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -73,6 +73,16 @@
     def with_action_not_found
       raise AbstractController::ActionNotFound
     end
+
+    def append_info_to_payload(payload)
+      super
+      payload[:test_key] = "test_value"
+      @last_payload = payload
+    end
+
+    def last_payload
+      @last_payload
+    end
   end
 end
 
@@ -163,6 +173,16 @@
     assert_match(/\(Views: [\d.]+ms\)/, logs[1])
   end
 
+  def test_append_info_to_payload_is_called_even_with_exception
+    begin
+      get :with_exception
+      wait
+    rescue Exception
+    end
+
+    assert_equal "test_value", @controller.last_payload[:test_key]
+  end
+
   def test_process_action_with_filter_parameters
     @request.env["action_dispatch.parameter_filter"] = [:lifo, :amount]
 
diff -Nru rails-4.1.8/actionpack/test/dispatch/request_test.rb rails-4.1.10/actionpack/test/dispatch/request_test.rb
--- rails-4.1.8/actionpack/test/dispatch/request_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/test/dispatch/request_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -729,8 +729,8 @@
       }
 
       parameter_filter = ActionDispatch::Http::ParameterFilter.new(filter_words)
-      before_filter['barg'] = {'bargain'=>'gain', 'blah'=>'bar', 'bar'=>{'bargain'=>{'blah'=>'foo'}}}
-      after_filter['barg']  = {'bargain'=>'niag', 'blah'=>'[FILTERED]', 'bar'=>{'bargain'=>{'blah'=>'[FILTERED]'}}}
+      before_filter['barg'] = {:bargain=>'gain', 'blah'=>'bar', 'bar'=>{'bargain'=>{'blah'=>'foo'}}}
+      after_filter['barg']  = {:bargain=>'niag', 'blah'=>'[FILTERED]', 'bar'=>{'bargain'=>{'blah'=>'[FILTERED]'}}}
 
       assert_equal after_filter, parameter_filter.filter(before_filter)
     end
@@ -878,6 +878,13 @@
     end
   end
 
+  test "reset variant" do
+    request = stub_request
+
+    request.variant = nil
+    assert_equal nil, request.variant
+  end
+
   test "setting variant with non symbol value" do
     request = stub_request
     assert_raise ArgumentError do
diff -Nru rails-4.1.8/actionpack/test/dispatch/routing_test.rb rails-4.1.10/actionpack/test/dispatch/routing_test.rb
--- rails-4.1.8/actionpack/test/dispatch/routing_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionpack/test/dispatch/routing_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -4238,3 +4238,31 @@
     assert_equal message, error.message
   end
 end
+
+class TestDefaultUrlOptions < ActionDispatch::IntegrationTest
+  class PostsController < ActionController::Base
+    def archive
+      render :text => "posts#archive"
+    end
+  end
+
+  Routes = ActionDispatch::Routing::RouteSet.new
+  Routes.draw do
+    default_url_options locale: 'en'
+    scope ':locale', format: false do
+      get '/posts/:year/:month/:day', to: 'posts#archive', as: 'archived_posts'
+    end
+  end
+
+  APP = build_app Routes
+
+  def app
+    APP
+  end
+
+  include Routes.url_helpers
+
+  def test_positional_args_with_format_false
+    assert_equal '/en/posts/2014/12/13', archived_posts_path(2014, 12, 13)
+  end
+end
diff -Nru rails-4.1.8/actionview/CHANGELOG.md rails-4.1.10/actionview/CHANGELOG.md
--- rails-4.1.8/actionview/CHANGELOG.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionview/CHANGELOG.md	2015-03-19 13:48:26.000000000 -0300
@@ -1,3 +1,27 @@
+## Rails 4.1.10 (March 19, 2015) ##
+
+*   Local variable in a partial is now available even if a falsy value is
+    passed to `:object` when rendering a partial.
+
+    Fixes #17373.
+
+    *Agis Anastasopoulos*
+
+*   Default translations that have a lower precidence than an html safe default,
+    but are not themselves safe, should not be marked as html_safe.
+
+    *Justin Coyne*
+
+## Rails 4.1.9 (January 6, 2015) ##
+
+*   Added an explicit error message, in `ActionView::PartialRenderer`
+    for partial `rendering`, when the value of option `as` has invalid characters.
+
+    *Angelo Capilleri*
+
+
+## Rails 4.1.8 (November 16, 2014) ##
+
 *   Update `select_tag` to work correctly with `:include_blank` option passing a string.
 
     Fixes #16483.
@@ -5,6 +29,16 @@
     *Frank Groeneveld*
 
 
+## Rails 4.1.7.1 (November 19, 2014) ##
+
+*   No changes.
+
+
+## Rails 4.1.7 (October 29, 2014) ##
+
+*   No changes.
+
+
 ## Rails 4.1.6 (September 11, 2014) ##
 
 *   Fix that render layout: 'messages/layout' should also be added to the dependency tracker tree.
diff -Nru rails-4.1.8/actionview/lib/action_view/gem_version.rb rails-4.1.10/actionview/lib/action_view/gem_version.rb
--- rails-4.1.8/actionview/lib/action_view/gem_version.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionview/lib/action_view/gem_version.rb	2015-03-19 13:48:26.000000000 -0300
@@ -7,7 +7,7 @@
   module VERSION
     MAJOR = 4
     MINOR = 1
-    TINY  = 8
+    TINY  = 10
     PRE   = nil
 
     STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
diff -Nru rails-4.1.8/actionview/lib/action_view/helpers/form_helper.rb rails-4.1.10/actionview/lib/action_view/helpers/form_helper.rb
--- rails-4.1.8/actionview/lib/action_view/helpers/form_helper.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionview/lib/action_view/helpers/form_helper.rb	2015-03-19 13:48:26.000000000 -0300
@@ -1142,11 +1142,11 @@
             object_name = model_name_from_record_or_class(object).param_key
           end
 
-          builder = options[:builder] || default_form_builder
+          builder = options[:builder] || default_form_builder_class
           builder.new(object_name, object, self, options)
         end
 
-        def default_form_builder
+        def default_form_builder_class
           builder = ActionView::Base.default_form_builder
           builder.respond_to?(:constantize) ? builder.constantize : builder
         end
@@ -1871,6 +1871,8 @@
   end
 
   ActiveSupport.on_load(:action_view) do
-    cattr_accessor(:default_form_builder) { ::ActionView::Helpers::FormBuilder }
+    cattr_accessor(:default_form_builder, instance_writer: false, instance_reader: false) do
+      ::ActionView::Helpers::FormBuilder
+    end
   end
 end
diff -Nru rails-4.1.8/actionview/lib/action_view/helpers/form_tag_helper.rb rails-4.1.10/actionview/lib/action_view/helpers/form_tag_helper.rb
--- rails-4.1.8/actionview/lib/action_view/helpers/form_tag_helper.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionview/lib/action_view/helpers/form_tag_helper.rb	2015-03-19 13:48:26.000000000 -0300
@@ -133,7 +133,9 @@
             include_blank = ''
           end
 
-          option_tags = content_tag(:option, include_blank, value: '').safe_concat(option_tags)
+          if include_blank
+            option_tags = content_tag(:option, include_blank, value: '').safe_concat(option_tags)
+          end
         end
 
         if prompt = options.delete(:prompt)
diff -Nru rails-4.1.8/actionview/lib/action_view/helpers/translation_helper.rb rails-4.1.10/actionview/lib/action_view/helpers/translation_helper.rb
--- rails-4.1.8/actionview/lib/action_view/helpers/translation_helper.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionview/lib/action_view/helpers/translation_helper.rb	2015-03-19 13:48:26.000000000 -0300
@@ -35,14 +35,22 @@
       # naming convention helps to identify translations that include HTML tags so that
       # you know what kind of output to expect when you call translate in a template.
       def translate(key, options = {})
-        options[:default] = wrap_translate_defaults(options[:default]) if options[:default]
+        options = options.dup
+        has_default = options.has_key?(:default)
+        remaining_defaults = Array(options.delete(:default))
 
-        # If the user has specified rescue_format then pass it all through, otherwise use
-        # raise and do the work ourselves
-        options[:raise] ||= ActionView::Base.raise_on_missing_translations
+        if has_default && !remaining_defaults.first.kind_of?(Symbol)
+          options[:default] = remaining_defaults.shift
+        end
 
-        raise_error = options[:raise] || options.key?(:rescue_format)
-        unless raise_error
+        # If the user has explicitly decided to NOT raise errors, pass that option to I18n.
+        # Otherwise, tell I18n to raise an exception, which we rescue further in this method.
+        # Note: `raise_error` refers to us re-raising the error in this method. I18n is forced to raise by default.
+        if options[:raise] == false || (options.key?(:rescue_format) && options[:rescue_format].nil?)
+          raise_error = false
+          options[:raise] = false
+        else
+          raise_error = options[:raise] || options[:rescue_format] || ActionView::Base.raise_on_missing_translations
           options[:raise] = true
         end
 
@@ -60,10 +68,14 @@
           I18n.translate(scope_key_by_partial(key), options)
         end
       rescue I18n::MissingTranslationData => e
-        raise e if raise_error
+        if remaining_defaults.present?
+          translate remaining_defaults.shift, options.merge(default: remaining_defaults)
+        else
+          raise e if raise_error
 
-        keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])
-        content_tag('span', keys.last.to_s.titleize, :class => 'translation_missing', :title => "translation missing: #{keys.join('.')}")
+          keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])
+          content_tag('span', keys.last.to_s.titleize, :class => 'translation_missing', :title => "translation missing: #{keys.join('.')}")
+        end
       end
       alias :t :translate
 
@@ -92,21 +104,6 @@
         def html_safe_translation_key?(key)
           key.to_s =~ /(\b|_|\.)html$/
         end
-
-        def wrap_translate_defaults(defaults)
-          new_defaults = []
-          defaults     = Array(defaults)
-          while key = defaults.shift
-            if key.is_a?(Symbol)
-              new_defaults << lambda { |_, options| translate key, options.merge(:default => defaults) }
-              break
-            else
-              new_defaults << key
-            end
-          end
-
-          new_defaults
-        end
     end
   end
 end
diff -Nru rails-4.1.8/actionview/lib/action_view/renderer/partial_renderer.rb rails-4.1.10/actionview/lib/action_view/renderer/partial_renderer.rb
--- rails-4.1.8/actionview/lib/action_view/renderer/partial_renderer.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionview/lib/action_view/renderer/partial_renderer.rb	2015-03-19 13:48:26.000000000 -0300
@@ -332,7 +332,7 @@
       prepend_formats(options[:formats])
 
       if String === partial
-        @object     = options[:object]
+        @object     = options[:object] if options.has_key?(:object)
         @path       = partial
         @collection = collection
       else
@@ -347,7 +347,7 @@
       end
 
       if as = options[:as]
-        raise_invalid_identifier(as) unless as.to_s =~ /\A[a-z_]\w*\z/
+        raise_invalid_option_as(as) unless as.to_s =~ /\A[a-z_]\w*\z/
         as = as.to_sym
       end
 
@@ -466,7 +466,7 @@
 
     def retrieve_template_keys
       keys = @locals.keys
-      keys << @variable         if @object || @collection
+      keys << @variable if defined?(@object) || @collection
       keys << @variable_counter if @collection
       keys
     end
@@ -482,11 +482,19 @@
     end
 
     IDENTIFIER_ERROR_MESSAGE = "The partial name (%s) is not a valid Ruby identifier; " +
-                               "make sure your partial name starts with a lowercase letter or underscore, " +
+                               "make sure your partial name starts with underscore, " +
+                               "and is followed by any combination of letters, numbers and underscores."
+
+    OPTION_AS_ERROR_MESSAGE  = "The value (%s) of the option `as` is not a valid Ruby identifier; " +
+                               "make sure it starts with lowercase letter, " +
                                "and is followed by any combination of letters, numbers and underscores."
 
     def raise_invalid_identifier(path)
       raise ArgumentError.new(IDENTIFIER_ERROR_MESSAGE % (path))
     end
+
+    def raise_invalid_option_as(as)
+      raise ArgumentError.new(OPTION_AS_ERROR_MESSAGE % (as))
+    end
   end
 end
diff -Nru rails-4.1.8/actionview/test/template/form_tag_helper_test.rb rails-4.1.10/actionview/test/template/form_tag_helper_test.rb
--- rails-4.1.8/actionview/test/template/form_tag_helper_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionview/test/template/form_tag_helper_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -222,6 +222,12 @@
     assert_dom_equal expected, actual
   end
 
+  def test_select_tag_with_include_blank_false
+    actual = select_tag "places", "<option>Home</option><option>Work</option><option>Pub</option>".html_safe, include_blank: false
+    expected = %(<select id="places" name="places"><option>Home</option><option>Work</option><option>Pub</option></select>)
+    assert_dom_equal expected, actual
+  end
+
   def test_select_tag_with_include_blank_string
     actual = select_tag "places", "<option>Home</option><option>Work</option><option>Pub</option>".html_safe, include_blank: 'Choose'
     expected = %(<select id="places" name="places"><option value="">Choose</option><option>Home</option><option>Work</option><option>Pub</option></select>)
diff -Nru rails-4.1.8/actionview/test/template/render_test.rb rails-4.1.10/actionview/test/template/render_test.rb
--- rails-4.1.8/actionview/test/template/render_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionview/test/template/render_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -176,14 +176,14 @@
   def test_render_partial_with_invalid_name
     e = assert_raises(ArgumentError) { @view.render(:partial => "test/200") }
     assert_equal "The partial name (test/200) is not a valid Ruby identifier; " +
-      "make sure your partial name starts with a lowercase letter or underscore, " +
+      "make sure your partial name starts with underscore, " +
       "and is followed by any combination of letters, numbers and underscores.", e.message
   end
 
   def test_render_partial_with_missing_filename
     e = assert_raises(ArgumentError) { @view.render(:partial => "test/") }
     assert_equal "The partial name (test/) is not a valid Ruby identifier; " +
-      "make sure your partial name starts with a lowercase letter or underscore, " +
+      "make sure your partial name starts with underscore, " +
       "and is followed by any combination of letters, numbers and underscores.", e.message
   end
 
@@ -195,7 +195,21 @@
   def test_render_partial_with_hyphen
     e = assert_raises(ArgumentError) { @view.render(:partial => "test/a-in") }
     assert_equal "The partial name (test/a-in) is not a valid Ruby identifier; " +
-      "make sure your partial name starts with a lowercase letter or underscore, " +
+      "make sure your partial name starts with underscore, " +
+      "and is followed by any combination of letters, numbers and underscores.", e.message
+  end
+
+  def test_render_partial_with_invalid_option_as
+    e = assert_raises(ArgumentError) { @view.render(:partial => "test/partial_only", :as => 'a-in') }
+    assert_equal "The value (a-in) of the option `as` is not a valid Ruby identifier; " +
+      "make sure it starts with lowercase letter, " +
+      "and is followed by any combination of letters, numbers and underscores.", e.message
+  end
+
+  def test_render_partial_with_hyphen_and_invalid_option_as
+    e = assert_raises(ArgumentError) { @view.render(:partial => "test/a-in", :as => 'a-in') }
+    assert_equal "The value (a-in) of the option `as` is not a valid Ruby identifier; " +
+      "make sure it starts with lowercase letter, " +
       "and is followed by any combination of letters, numbers and underscores.", e.message
   end
 
diff -Nru rails-4.1.8/actionview/test/template/translation_helper_test.rb rails-4.1.10/actionview/test/template/translation_helper_test.rb
--- rails-4.1.8/actionview/test/template/translation_helper_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/actionview/test/template/translation_helper_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -1,5 +1,13 @@
 require 'abstract_unit'
 
+module I18n
+  class CustomExceptionHandler
+    def self.call(exception, locale, key, options)
+      'from CustomExceptionHandler'
+    end
+  end
+end
+
 class TranslationHelperTest < ActiveSupport::TestCase
   include ActionView::Helpers::TranslationHelper
 
@@ -68,6 +76,22 @@
     end
   end
 
+  def test_uses_custom_exception_handler_when_specified
+    old_exception_handler = I18n.exception_handler
+    I18n.exception_handler = I18n::CustomExceptionHandler
+    assert_equal 'from CustomExceptionHandler', translate(:"translations.missing", raise: false)
+  ensure
+    I18n.exception_handler = old_exception_handler
+  end
+
+  def test_uses_custom_exception_handler_when_specified_for_html
+    old_exception_handler = I18n.exception_handler
+    I18n.exception_handler = I18n::CustomExceptionHandler
+    assert_equal 'from CustomExceptionHandler', translate(:"translations.missing_html", raise: false)
+  ensure
+    I18n.exception_handler = old_exception_handler
+  end
+
   def test_i18n_translate_defaults_to_nil_rescue_format
     expected = 'translation missing: en.translations.missing'
     assert_equal expected, I18n.translate(:"translations.missing")
@@ -141,11 +165,22 @@
     assert_equal true, translation.html_safe?
   end
 
+  def test_translate_with_last_default_not_named_html
+    translation = translate(:'translations.missing', :default => [:'translations.missing_html', :'translations.foo'])
+    assert_equal 'Foo', translation
+    assert_equal false, translation.html_safe?
+  end
+
   def test_translate_with_string_default
     translation = translate(:'translations.missing', default: 'A Generic String')
     assert_equal 'A Generic String', translation
   end
 
+  def test_translate_with_object_default
+    translation = translate(:'translations.missing', default: 123)
+    assert_equal 123, translation
+  end
+
   def test_translate_with_array_of_string_defaults
     translation = translate(:'translations.missing', default: ['A Generic String', 'Second generic string'])
     assert_equal 'A Generic String', translation
diff -Nru rails-4.1.8/activemodel/CHANGELOG.md rails-4.1.10/activemodel/CHANGELOG.md
--- rails-4.1.8/activemodel/CHANGELOG.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activemodel/CHANGELOG.md	2015-03-19 13:48:26.000000000 -0300
@@ -1,3 +1,28 @@
+## Rails 4.1.10 (March 19, 2015) ##
+
+*   No changes.
+
+
+## Rails 4.1.9 (January 6, 2015) ##
+
+*   No changes.
+
+
+## Rails 4.1.8 (November 16, 2014) ##
+
+*   No changes.
+
+
+## Rails 4.1.7.1 (November 19, 2014) ##
+
+*   No changes.
+
+
+## Rails 4.1.7 (October 29, 2014) ##
+
+*   No changes.
+
+
 ## Rails 4.1.6 (September 11, 2014) ##
 
 *   No changes.
diff -Nru rails-4.1.8/activemodel/lib/active_model/gem_version.rb rails-4.1.10/activemodel/lib/active_model/gem_version.rb
--- rails-4.1.8/activemodel/lib/active_model/gem_version.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activemodel/lib/active_model/gem_version.rb	2015-03-19 13:48:26.000000000 -0300
@@ -7,7 +7,7 @@
   module VERSION
     MAJOR = 4
     MINOR = 1
-    TINY  = 8
+    TINY  = 10
     PRE   = nil
 
     STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
diff -Nru rails-4.1.8/activerecord/CHANGELOG.md rails-4.1.10/activerecord/CHANGELOG.md
--- rails-4.1.8/activerecord/CHANGELOG.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/CHANGELOG.md	2015-03-19 13:48:26.000000000 -0300
@@ -1,3 +1,105 @@
+## Rails 4.1.10 (March 19, 2015) ##
+
+*   Fixed ActiveRecord::Relation#becomes! and changed_attributes issues for type column
+
+    Fixes #17139.
+
+    *Miklos Fazekas*
+
+*   A `NullRelation` should represent nothing. This fixes a bug where
+    `Comment.where(post_id: Post.none)` returned a non-empty result.
+
+    Closes #15176.
+
+    *Matthew Draper*, *Yves Senn*
+
+*   Respect custom primary keys for associations when calling `Relation#where`
+
+    Fixes #18813.
+
+    *Sean Griffin*
+
+*   Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
+
+      SplitTest.group(:key).count
+      Property.group(:value).count
+
+    *Bogdan Gusiev*
+
+*   Fixed setting of foreign_key for through associations while building of new record.
+
+    Fixes #12698.
+
+    *Ivan Antropov*
+
+*   Fixed automatic inverse_of for models nested in module.
+
+    *Andrew McCloud*
+
+*   Fix `reaping_frequency` option when the value is a string.
+
+    This usually happens when it is configured using `DATABASE_URL`.
+
+    *korbin*
+
+
+## Rails 4.1.9 (January 6, 2015) ##
+
+*   `db:schema:load` and `db:structure:load` no longer purge the database
+    before loading the schema. This is left for the user to do.
+    `db:test:prepare` will still purge the database.
+
+    Closes #17945.
+
+    *Yves Senn*
+
+*   Bring back `db:test:prepare` to synchronize the test database schema.
+
+    Manual synchronization using `bin/rake db:test:prepare` is required
+    when a migration is rolled-back, edited and reapplied.
+
+    `ActiveRecord::Base.maintain_test_schema` now uses `db:test:prepare`
+    to synchronize the schema. Plugins can use this task as a hook to
+    provide custom behavior after the schema has been loaded.
+
+    NOTE: `test:prepare` runs before the schema was synchronized.
+
+    Fixes #17171, #15787.
+
+    *Yves Senn*
+
+*   Renaming a table in pg also renames the primary key index.
+
+    Fixes #12856
+
+    *Sean Griffin*
+
+*   Make it possible to access fixtures excluded by a `default_scope`.
+
+    *Yves Senn*
+
+*   `timestamps` and `add_timestamps` passes additional options along.
+    (like `null: false`)
+
+    Closes #17624.
+
+    *Yves Senn*
+
+
+## Rails 4.1.8 (November 16, 2014) ##
+
+*   Cache `CollectionAssociation#reader` proxies separately before and after
+    the owner has been saved so that the proxy is not cached without the
+    owner's id.
+
+    *Ben Woosley*
+
+*   Fix preloading of associations which unscope a default scope.
+
+    Fixes #11036.
+
+    *Byron Bischoff*
+
 *   Do not use `RENAME INDEX` syntax for MariaDB 10.0.
 
     Fixes #15931.
@@ -36,6 +138,16 @@
     *Agis Anastasopoulos*
 
 
+## Rails 4.1.7.1 (November 19, 2014) ##
+
+*   No changes.
+
+
+## Rails 4.1.7 (October 29, 2014) ##
+
+*   No changes.
+
+
 ## Rails 4.1.6 (September 11, 2014) ##
 
 *   Fixed a regression where whitespaces were stripped from DISTINCT queries in
diff -Nru rails-4.1.8/activerecord/lib/active_record/associations/association_scope.rb rails-4.1.10/activerecord/lib/active_record/associations/association_scope.rb
--- rails-4.1.8/activerecord/lib/active_record/associations/association_scope.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/associations/association_scope.rb	2015-03-19 13:48:26.000000000 -0300
@@ -143,11 +143,7 @@
       end
 
       def eval_scope(klass, scope, owner)
-        if scope.is_a?(Relation)
-          scope
-        else
-          klass.unscoped.instance_exec(owner, &scope)
-        end
+        klass.unscoped.instance_exec(owner, &scope)
       end
     end
   end
diff -Nru rails-4.1.8/activerecord/lib/active_record/associations/collection_association.rb rails-4.1.10/activerecord/lib/active_record/associations/collection_association.rb
--- rails-4.1.8/activerecord/lib/active_record/associations/collection_association.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/associations/collection_association.rb	2015-03-19 13:48:26.000000000 -0300
@@ -33,7 +33,13 @@
           reload
         end
 
-        @proxy ||= CollectionProxy.create(klass, self)
+        if owner.new_record?
+          # Cache the proxy separately before the owner has an id
+          # or else a post-save proxy will still lack the id
+          @new_record_proxy ||= CollectionProxy.create(klass, self)
+        else
+          @proxy ||= CollectionProxy.create(klass, self)
+        end
       end
 
       # Implements the writer method, e.g. foo.items= for Foo.has_many :items
@@ -123,6 +129,16 @@
         first_nth_or_last(:last, *args)
       end
 
+      def take(n = nil)
+        if loaded?
+          n ? target.take(n) : target.first
+        else
+          scope.take(n).tap do |record|
+            set_inverse_instance record if record.is_a? ActiveRecord::Base
+          end
+        end
+      end
+
       def build(attributes = {}, &block)
         if attributes.is_a?(Array)
           attributes.collect { |attr| build(attr, &block) }
@@ -560,8 +576,13 @@
           if reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
             assoc = owner.association(reflection.through_reflection.name)
             assoc.reader.any? { |source|
-              target = source.send(reflection.source_reflection.name)
-              target.respond_to?(:include?) ? target.include?(record) : target == record
+              target_association = source.send(reflection.source_reflection.name)
+
+              if target_association.respond_to?(:include?)
+                target_association.include?(record)
+              else
+                target_association == record
+              end
             } || target.include?(record)
           else
             target.include?(record)
diff -Nru rails-4.1.8/activerecord/lib/active_record/associations/collection_proxy.rb rails-4.1.10/activerecord/lib/active_record/associations/collection_proxy.rb
--- rails-4.1.8/activerecord/lib/active_record/associations/collection_proxy.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/associations/collection_proxy.rb	2015-03-19 13:48:26.000000000 -0300
@@ -226,6 +226,10 @@
         @association.last(*args)
       end
 
+      def take(n = nil)
+        @association.take(n)
+      end
+
       # Returns a new object of the collection type that has been instantiated
       # with +attributes+ and linked to this object, but have not yet been saved.
       # You can pass an array of attributes hashes, this will return an array
diff -Nru rails-4.1.8/activerecord/lib/active_record/associations/preloader/association.rb rails-4.1.10/activerecord/lib/active_record/associations/preloader/association.rb
--- rails-4.1.8/activerecord/lib/active_record/associations/preloader/association.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/associations/preloader/association.rb	2015-03-19 13:48:26.000000000 -0300
@@ -154,6 +154,7 @@
             scope.where!(klass.table_name => { reflection.type => model.base_class.sti_name })
           end
 
+          scope.unscope_values = Array(values[:unscope])
           klass.default_scoped.merge(scope)
         end
       end
diff -Nru rails-4.1.8/activerecord/lib/active_record/associations/preloader.rb rails-4.1.10/activerecord/lib/active_record/associations/preloader.rb
--- rails-4.1.8/activerecord/lib/active_record/associations/preloader.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/associations/preloader.rb	2015-03-19 13:48:26.000000000 -0300
@@ -169,6 +169,7 @@
       class NullPreloader
         def self.new(klass, owners, reflection, preload_scope); self; end
         def self.run(preloader); end
+        def self.preloaded_records; []; end
       end
 
       def preloader_for(reflection, owners, rhs_klass)
diff -Nru rails-4.1.8/activerecord/lib/active_record/associations/through_association.rb rails-4.1.10/activerecord/lib/active_record/associations/through_association.rb
--- rails-4.1.8/activerecord/lib/active_record/associations/through_association.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/associations/through_association.rb	2015-03-19 13:48:26.000000000 -0300
@@ -92,6 +92,17 @@
             raise HasManyThroughNestedAssociationsAreReadonly.new(owner, reflection)
           end
         end
+
+        def build_record(attributes)
+          inverse = source_reflection.inverse_of
+          target = through_association.target
+
+          if inverse && target && !target.is_a?(Array)
+            attributes[inverse.foreign_key] = target.id
+          end
+
+          super(attributes)
+        end
     end
   end
 end
diff -Nru rails-4.1.8/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb rails-4.1.10/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
--- rails-4.1.8/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb	2015-03-19 13:48:26.000000000 -0300
@@ -34,7 +34,7 @@
           if create_time_zone_conversion_attribute?(attr_name, columns_hash[attr_name])
             method_body, line = <<-EOV, __LINE__ + 1
               def #{attr_name}=(time)
-                time_with_zone = time.respond_to?(:in_time_zone) ? time.in_time_zone : nil
+                time_with_zone = convert_value_to_time_zone("#{attr_name}", time)
                 previous_time = attribute_changed?("#{attr_name}") ? changed_attributes["#{attr_name}"] : read_attribute(:#{attr_name})
                 write_attribute(:#{attr_name}, time)
                 #{attr_name}_will_change! if previous_time != time_with_zone
@@ -54,6 +54,18 @@
             (:datetime == column.type || :timestamp == column.type)
         end
       end
+
+      private
+
+      def convert_value_to_time_zone(attr_name, value)
+        if value.is_a?(Array)
+          value.map { |v| convert_value_to_time_zone(attr_name, v) }
+        elsif value.respond_to?(:in_time_zone)
+          value.in_time_zone || self.class.columns_hash[attr_name].type_cast(value)
+        else
+          nil
+        end
+      end
     end
   end
 end
diff -Nru rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb	2015-03-19 13:48:26.000000000 -0300
@@ -238,7 +238,7 @@
 
         @checkout_timeout = (spec.config[:checkout_timeout] && spec.config[:checkout_timeout].to_f) || 5
         @dead_connection_timeout = (spec.config[:dead_connection_timeout] && spec.config[:dead_connection_timeout].to_f) || 5
-        @reaper  = Reaper.new self, spec.config[:reaping_frequency]
+        @reaper = Reaper.new(self, (spec.config[:reaping_frequency] && spec.config[:reaping_frequency].to_f))
         @reaper.run
 
         # default max pool size to 5
diff -Nru rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb	2015-03-19 13:48:26.000000000 -0300
@@ -394,8 +394,8 @@
       # Adds timestamps (+created_at+ and +updated_at+) columns to the table. See SchemaStatements#add_timestamps
       #
       #  t.timestamps
-      def timestamps
-        @base.add_timestamps(@table_name)
+      def timestamps(options = {})
+        @base.add_timestamps(@table_name, options)
       end
 
       # Changes the column's definition according to the new options.
diff -Nru rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb	2015-03-19 13:48:26.000000000 -0300
@@ -722,9 +722,9 @@
       #
       #   add_timestamps(:suppliers)
       #
-      def add_timestamps(table_name)
-        add_column table_name, :created_at, :datetime
-        add_column table_name, :updated_at, :datetime
+      def add_timestamps(table_name, options = {})
+        add_column table_name, :created_at, :datetime, options
+        add_column table_name, :updated_at, :datetime, options
       end
 
       # Removes the timestamp columns (+created_at+ and +updated_at+) from the table definition.
diff -Nru rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb	2015-03-19 13:48:26.000000000 -0300
@@ -356,7 +356,12 @@
       protected
 
       def translate_exception_class(e, sql)
-        message = "#{e.class.name}: #{e.message}: #{sql}"
+        begin
+          message = "#{e.class.name}: #{e.message}: #{sql}"
+        rescue Encoding::CompatibilityError
+          message = "#{e.class.name}: #{e.message.force_encoding sql.encoding}: #{sql}"
+        end
+
         @logger.error message if @logger
         exception = translate_exception(e, message)
         exception.set_backtrace e.backtrace
diff -Nru rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb	2015-03-19 13:48:26.000000000 -0300
@@ -717,8 +717,8 @@
         "DROP INDEX #{index_name}"
       end
 
-      def add_timestamps_sql(table_name)
-        [add_column_sql(table_name, :created_at, :datetime), add_column_sql(table_name, :updated_at, :datetime)]
+      def add_timestamps_sql(table_name, options = {})
+        [add_column_sql(table_name, :created_at, :datetime, options), add_column_sql(table_name, :updated_at, :datetime, options)]
       end
 
       def remove_timestamps_sql(table_name)
diff -Nru rails-4.1.8/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb rails-4.1.10/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb	2015-03-19 13:48:26.000000000 -0300
@@ -27,6 +27,9 @@
         class Bytea < Type
           def type_cast(value)
             return if value.nil?
+            # This is a flawed heuristic, but it avoids truncation;
+            # we really shouldn’t be calling this with already-unescaped values
+            return value if value.dup.force_encoding("BINARY") =~ /\x00/
             PGconn.unescape_bytea value
           end
         end
diff -Nru rails-4.1.8/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb rails-4.1.10/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
--- rails-4.1.8/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb	2015-03-19 13:48:26.000000000 -0300
@@ -382,7 +382,10 @@
           pk, seq = pk_and_sequence_for(new_name)
           if seq == "#{table_name}_#{pk}_seq"
             new_seq = "#{new_name}_#{pk}_seq"
+            idx = "#{table_name}_pkey"
+            new_idx = "#{new_name}_pkey"
             execute "ALTER TABLE #{quote_table_name(seq)} RENAME TO #{quote_table_name(new_seq)}"
+            execute "ALTER INDEX #{quote_table_name(idx)} RENAME TO #{quote_table_name(new_idx)}"
           end
 
           rename_table_indexes(table_name, new_name)
diff -Nru rails-4.1.8/activerecord/lib/active_record/core.rb rails-4.1.10/activerecord/lib/active_record/core.rb
--- rails-4.1.8/activerecord/lib/active_record/core.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/core.rb	2015-03-19 13:48:26.000000000 -0300
@@ -85,7 +85,6 @@
       mattr_accessor :dump_schema_after_migration, instance_writer: false
       self.dump_schema_after_migration = true
 
-      # :nodoc:
       mattr_accessor :maintain_test_schema, instance_accessor: false
 
       def self.disable_implicit_join_references=(value)
diff -Nru rails-4.1.8/activerecord/lib/active_record/fixtures.rb rails-4.1.10/activerecord/lib/active_record/fixtures.rb
--- rails-4.1.8/activerecord/lib/active_record/fixtures.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/fixtures.rb	2015-03-19 13:48:26.000000000 -0300
@@ -790,7 +790,7 @@
 
     def find
       if model_class
-        model_class.find(fixture[model_class.primary_key])
+        model_class.unscoped.find(fixture[model_class.primary_key])
       else
         raise FixtureClassNotFound, "No class attached to find."
       end
diff -Nru rails-4.1.8/activerecord/lib/active_record/gem_version.rb rails-4.1.10/activerecord/lib/active_record/gem_version.rb
--- rails-4.1.8/activerecord/lib/active_record/gem_version.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/gem_version.rb	2015-03-19 13:48:26.000000000 -0300
@@ -7,7 +7,7 @@
   module VERSION
     MAJOR = 4
     MINOR = 1
-    TINY  = 8
+    TINY  = 10
     PRE   = nil
 
     STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
diff -Nru rails-4.1.8/activerecord/lib/active_record/migration.rb rails-4.1.10/activerecord/lib/active_record/migration.rb
--- rails-4.1.8/activerecord/lib/active_record/migration.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/migration.rb	2015-03-19 13:48:26.000000000 -0300
@@ -391,7 +391,14 @@
 
       def load_schema_if_pending!
         if ActiveRecord::Migrator.needs_migration?
-          ActiveRecord::Tasks::DatabaseTasks.load_schema_current
+          # Roundrip to Rake to allow plugins to hook into database initialization.
+          FileUtils.cd Rails.root do
+            current_config = Base.connection_config
+            Base.clear_all_connections!
+            system("bin/rake db:test:prepare")
+            # Establish a new connection, the old database may be gone (db:test:prepare uses purge)
+            Base.establish_connection(current_config)
+          end
           check_pending!
         end
       end
diff -Nru rails-4.1.8/activerecord/lib/active_record/persistence.rb rails-4.1.10/activerecord/lib/active_record/persistence.rb
--- rails-4.1.8/activerecord/lib/active_record/persistence.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/persistence.rb	2015-03-19 13:48:26.000000000 -0300
@@ -181,7 +181,8 @@
       became = klass.new
       became.instance_variable_set("@attributes", @attributes)
       became.instance_variable_set("@attributes_cache", @attributes_cache)
-      became.instance_variable_set("@changed_attributes", @changed_attributes) if defined?(@changed_attributes)
+      changed_attributes = @changed_attributes if defined?(@changed_attributes)
+      became.instance_variable_set("@changed_attributes", changed_attributes || {})
       became.instance_variable_set("@new_record", new_record?)
       became.instance_variable_set("@destroyed", destroyed?)
       became.instance_variable_set("@errors", errors)
diff -Nru rails-4.1.8/activerecord/lib/active_record/railtie.rb rails-4.1.10/activerecord/lib/active_record/railtie.rb
--- rails-4.1.8/activerecord/lib/active_record/railtie.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/railtie.rb	2015-03-19 13:48:26.000000000 -0300
@@ -36,8 +36,6 @@
     config.eager_load_namespaces << ActiveRecord
 
     rake_tasks do
-      require "active_record/base"
-
       namespace :db do
         task :load_config do
           ActiveRecord::Tasks::DatabaseTasks.database_configuration = Rails.application.config.database_configuration
diff -Nru rails-4.1.8/activerecord/lib/active_record/railties/databases.rake rails-4.1.10/activerecord/lib/active_record/railties/databases.rake
--- rails-4.1.8/activerecord/lib/active_record/railties/databases.rake	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/railties/databases.rake	2015-03-19 13:48:26.000000000 -0300
@@ -234,7 +234,7 @@
     end
 
     desc 'Load a schema.rb file into the database'
-    task :load => [:environment, :load_config] do
+    task :load => [:load_config] do
       ActiveRecord::Tasks::DatabaseTasks.load_schema_current(:ruby, ENV['SCHEMA'])
     end
 
@@ -299,7 +299,7 @@
     end
 
     # desc "Recreate the test database from the current schema"
-    task :load => %w(db:test:deprecated db:test:purge) do
+    task :load => %w(db:test:purge) do
       case ActiveRecord::Base.schema_format
         when :ruby
           db_namespace["test:load_schema"].invoke
@@ -309,7 +309,7 @@
     end
 
     # desc "Recreate the test database from an existent schema.rb file"
-    task :load_schema => %w(db:test:deprecated db:test:purge) do
+    task :load_schema => %w(db:test:purge) do
       begin
         should_reconnect = ActiveRecord::Base.connection_pool.active_connection?
         ActiveRecord::Schema.verbose = false
@@ -322,7 +322,7 @@
     end
 
     # desc "Recreate the test database from an existent structure.sql file"
-    task :load_structure => %w(db:test:deprecated db:test:purge) do
+    task :load_structure => %w(db:test:purge) do
       ActiveRecord::Tasks::DatabaseTasks.load_schema_for ActiveRecord::Base.configurations['test'], :sql, ENV['SCHEMA']
     end
 
@@ -343,12 +343,12 @@
     task :clone_structure => %w(db:test:deprecated db:structure:dump db:test:load_structure)
 
     # desc "Empty the test database"
-    task :purge => %w(db:test:deprecated environment load_config) do
+    task :purge => %w(environment load_config) do
       ActiveRecord::Tasks::DatabaseTasks.purge ActiveRecord::Base.configurations['test']
     end
 
     # desc 'Check for pending migrations and load the test schema'
-    task :prepare => %w(db:test:deprecated environment load_config) do
+    task :prepare => %w(environment load_config) do
       unless ActiveRecord::Base.configurations.blank?
         db_namespace['test:load'].invoke
       end
diff -Nru rails-4.1.8/activerecord/lib/active_record/reflection.rb rails-4.1.10/activerecord/lib/active_record/reflection.rb
--- rails-4.1.8/activerecord/lib/active_record/reflection.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/reflection.rb	2015-03-19 13:48:26.000000000 -0300
@@ -432,7 +432,7 @@
         # returns either nil or the inverse association name that it finds.
         def automatic_inverse_of
           if can_find_inverse_of_automatically?(self)
-            inverse_name = ActiveSupport::Inflector.underscore(options[:as] || active_record.name).to_sym
+            inverse_name = ActiveSupport::Inflector.underscore(options[:as] || active_record.name.demodulize).to_sym
 
             begin
               reflection = klass._reflect_on_association(inverse_name)
@@ -609,8 +609,11 @@
           through_scope_chain = through_reflection.scope_chain.map(&:dup)
 
           if options[:source_type]
-            through_scope_chain.first <<
-              through_reflection.klass.where(foreign_type => options[:source_type])
+            type = foreign_type
+            source_type = options[:source_type]
+            through_scope_chain.first << lambda { |object|
+              where(type => source_type)
+            }
           end
 
           # Recursively fill out the rest of the array from the through reflection
diff -Nru rails-4.1.8/activerecord/lib/active_record/relation/batches.rb rails-4.1.10/activerecord/lib/active_record/relation/batches.rb
--- rails-4.1.8/activerecord/lib/active_record/relation/batches.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/relation/batches.rb	2015-03-19 13:48:26.000000000 -0300
@@ -115,6 +115,7 @@
       end
 
       relation = relation.reorder(batch_order).limit(batch_size)
+      relation.reverse_order_value = false
       records = start ? relation.where(table[primary_key].gteq(start)).to_a : relation.to_a
 
       while records.any?
diff -Nru rails-4.1.8/activerecord/lib/active_record/relation/predicate_builder/relation_handler.rb rails-4.1.10/activerecord/lib/active_record/relation/predicate_builder/relation_handler.rb
--- rails-4.1.8/activerecord/lib/active_record/relation/predicate_builder/relation_handler.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/relation/predicate_builder/relation_handler.rb	2015-03-19 13:48:26.000000000 -0300
@@ -6,6 +6,10 @@
           value = value.select(value.klass.arel_table[value.klass.primary_key])
         end
 
+        value = value.dup
+        value.where_values = value.where_values.map do |node|
+          node.dup rescue node
+        end
         attribute.in(value.arel.ast)
       end
     end
diff -Nru rails-4.1.8/activerecord/lib/active_record/relation/predicate_builder.rb rails-4.1.10/activerecord/lib/active_record/relation/predicate_builder.rb
--- rails-4.1.8/activerecord/lib/active_record/relation/predicate_builder.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/relation/predicate_builder.rb	2015-03-19 13:48:26.000000000 -0300
@@ -61,6 +61,8 @@
         end
 
         column = reflection.foreign_key
+        primary_key = reflection.association_primary_key(base_class)
+        value = convert_value_to_association_ids(value, primary_key)
       end
 
       queries << build(table[column], value)
@@ -114,12 +116,28 @@
     register_handler(Array, ArrayHandler.new)
 
     private
-      def self.build(attribute, value)
-        handler_for(value).call(attribute, value)
-      end
 
-      def self.handler_for(object)
-        @handlers.detect { |klass, _| klass === object }.last
+    def self.build(attribute, value)
+      handler_for(value).call(attribute, value)
+    end
+    private_class_method :build
+
+    def self.handler_for(object)
+      @handlers.detect { |klass, _| klass === object }.last
+    end
+    private_class_method :handler_for
+
+    def self.convert_value_to_association_ids(value, primary_key)
+      case value
+      when Relation
+        value.select(primary_key)
+      when Array
+        value.map { |v| convert_value_to_association_ids(v, primary_key) }
+      when Base
+        value.read_attribute(primary_key)
+      else
+        value
       end
+    end
   end
 end
diff -Nru rails-4.1.8/activerecord/lib/active_record/relation/query_methods.rb rails-4.1.10/activerecord/lib/active_record/relation/query_methods.rb
--- rails-4.1.8/activerecord/lib/active_record/relation/query_methods.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/relation/query_methods.rb	2015-03-19 13:48:26.000000000 -0300
@@ -677,11 +677,11 @@
     #   end
     #
     def none
-      extending(NullRelation)
+      where("1=0").extending!(NullRelation)
     end
 
     def none! # :nodoc:
-      extending!(NullRelation)
+      where!("1=0").extending!(NullRelation)
     end
 
     # Sets readonly attributes for the returned relation. If value is
@@ -855,12 +855,11 @@
 
       arel.take(connection.sanitize_limit(limit_value)) if limit_value
       arel.skip(offset_value.to_i) if offset_value
-
-      arel.group(*group_values.uniq.reject(&:blank?)) unless group_values.empty?
+      arel.group(*arel_columns(group_values.uniq.reject(&:blank?))) unless group_values.empty?
 
       build_order(arel)
 
-      build_select(arel, select_values.uniq)
+      build_select(arel)
 
       arel.distinct(distinct_value)
       arel.from(build_from) if from_value
@@ -1008,17 +1007,24 @@
       manager
     end
 
-    def build_select(arel, selects)
-      if !selects.empty?
-        expanded_select = selects.map do |field|
-          columns_hash.key?(field.to_s) ? arel_table[field] : field
-        end
-        arel.project(*expanded_select)
+    def build_select(arel)
+      if select_values.any?
+        arel.project(*arel_columns(select_values.uniq))
       else
         arel.project(@klass.arel_table[Arel.star])
       end
     end
 
+    def arel_columns(columns)
+      columns.map do |field|
+        if columns_hash.key?(field.to_s)
+          arel_table[field]
+        else
+          field
+        end
+      end
+    end
+
     def reverse_sql_order(order_query)
       order_query = ["#{quoted_table_name}.#{quoted_primary_key} ASC"] if order_query.empty?
 
diff -Nru rails-4.1.8/activerecord/lib/active_record/tasks/database_tasks.rb rails-4.1.10/activerecord/lib/active_record/tasks/database_tasks.rb
--- rails-4.1.8/activerecord/lib/active_record/tasks/database_tasks.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/tasks/database_tasks.rb	2015-03-19 13:48:26.000000000 -0300
@@ -167,13 +167,11 @@
         when :ruby
           file ||= File.join(db_dir, "schema.rb")
           check_schema_file(file)
-          purge(configuration)
           ActiveRecord::Base.establish_connection(configuration)
           load(file)
         when :sql
           file ||= File.join(db_dir, "structure.sql")
           check_schema_file(file)
-          purge(configuration)
           structure_load(configuration, file)
         else
           raise ArgumentError, "unknown format #{format.inspect}"
diff -Nru rails-4.1.8/activerecord/lib/active_record/transactions.rb rails-4.1.10/activerecord/lib/active_record/transactions.rb
--- rails-4.1.8/activerecord/lib/active_record/transactions.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/transactions.rb	2015-03-19 13:48:26.000000000 -0300
@@ -249,7 +249,7 @@
 
       def assert_valid_transaction_action(actions)
         if (actions - ACTIONS).any?
-          raise ArgumentError, ":on conditions for after_commit and after_rollback callbacks have to be one of #{ACTIONS.join(",")}"
+          raise ArgumentError, ":on conditions for after_commit and after_rollback callbacks have to be one of #{ACTIONS}"
         end
       end
     end
diff -Nru rails-4.1.8/activerecord/lib/active_record/validations/uniqueness.rb rails-4.1.10/activerecord/lib/active_record/validations/uniqueness.rb
--- rails-4.1.8/activerecord/lib/active_record/validations/uniqueness.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/lib/active_record/validations/uniqueness.rb	2015-03-19 13:48:26.000000000 -0300
@@ -81,7 +81,15 @@
           else
             scope_value = record.read_attribute(scope_item)
           end
-          relation = relation.and(table[scope_item].eq(scope_value))
+
+          # This is basically emulating an Arel::Nodes::Casted
+          column = record.class.columns_hash[scope_item.to_s]
+          quoted_value = record.class.connection.quote(scope_value, column)
+          unless scope_value.nil?
+            node = Arel::Nodes::SqlLiteral.new(quoted_value)
+          end
+
+          relation = relation.and(table[scope_item].eq(node))
         end
 
         relation
diff -Nru rails-4.1.8/activerecord/test/cases/adapters/postgresql/array_test.rb rails-4.1.10/activerecord/test/cases/adapters/postgresql/array_test.rb
--- rails-4.1.8/activerecord/test/cases/adapters/postgresql/array_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/adapters/postgresql/array_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -4,6 +4,8 @@
 require 'active_record/connection_adapters/postgresql_adapter'
 
 class PostgresqlArrayTest < ActiveRecord::TestCase
+  include InTimeZone
+
   class PgArray < ActiveRecord::Base
     self.table_name = 'pg_arrays'
   end
@@ -14,6 +16,7 @@
       @connection.create_table('pg_arrays') do |t|
         t.string 'tags', array: true
         t.integer 'ratings', array: true
+        t.datetime :datetimes, array: true
       end
     end
     @column = PgArray.columns.find { |c| c.name == 'tags' }
@@ -180,6 +183,24 @@
     assert_equal [], pg_array.reload.tags
   end
 
+  def test_datetime_with_timezone_awareness
+    tz = "Pacific Time (US & Canada)"
+
+    in_time_zone tz do
+      PgArray.reset_column_information
+      time_string = Time.current.to_s
+      time = Time.zone.parse(time_string)
+
+      record = PgArray.new(datetimes: [time_string])
+      assert_equal [time], record.datetimes
+
+      record.save!
+      record.reload
+
+      assert_equal [time], record.datetimes
+    end
+  end
+
   private
   def assert_cycle field, array
     # test creation
diff -Nru rails-4.1.8/activerecord/test/cases/adapters/postgresql/datatype_test.rb rails-4.1.10/activerecord/test/cases/adapters/postgresql/datatype_test.rb
--- rails-4.1.8/activerecord/test/cases/adapters/postgresql/datatype_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/adapters/postgresql/datatype_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -166,11 +166,11 @@
   end
 
   def test_number_values
-    assert_equal 123.456, @first_number.single
-    assert_equal 123456.789, @first_number.double
-    assert_equal -::Float::INFINITY, @second_number.single
-    assert_equal ::Float::INFINITY, @second_number.double
-    assert_same ::Float::NAN, @third_number.double
+    assert_equal(123.456, @first_number.single)
+    assert_equal(123456.789, @first_number.double)
+    assert_equal(-::Float::INFINITY, @second_number.single)
+    assert_equal(::Float::INFINITY, @second_number.double)
+    assert_same(::Float::NAN, @third_number.double)
   end
 
   def test_time_values
diff -Nru rails-4.1.8/activerecord/test/cases/adapters/postgresql/infinity_test.rb rails-4.1.10/activerecord/test/cases/adapters/postgresql/infinity_test.rb
--- rails-4.1.8/activerecord/test/cases/adapters/postgresql/infinity_test.rb	1969-12-31 21:00:00.000000000 -0300
+++ rails-4.1.10/activerecord/test/cases/adapters/postgresql/infinity_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -0,0 +1,34 @@
+require "cases/helper"
+
+class PostgresqlInfinityTest < ActiveRecord::TestCase
+  include InTimeZone
+
+  class PostgresqlInfinity < ActiveRecord::Base
+  end
+
+  setup do
+    @connection = ActiveRecord::Base.connection
+    @connection.create_table(:postgresql_infinities, force: true) do |t|
+      t.float :float
+      t.datetime :datetime
+    end
+  end
+
+  teardown do
+    @connection.execute("DROP TABLE IF EXISTS postgresql_infinities")
+  end
+
+  test "assigning 'infinity' on a datetime column with TZ aware attributes" do
+    begin
+      in_time_zone "Pacific Time (US & Canada)" do
+        record = PostgresqlInfinity.create!(datetime: "infinity")
+        assert_equal Float::INFINITY, record.datetime
+        assert_equal record.datetime, record.reload.datetime
+      end
+    ensure
+      # setting time_zone_aware_attributes causes the types to change.
+      # There is no way to do this automatically since it can be set on a superclass
+      PostgresqlInfinity.reset_column_information
+    end
+  end
+end
diff -Nru rails-4.1.8/activerecord/test/cases/adapters/postgresql/rename_table_test.rb rails-4.1.10/activerecord/test/cases/adapters/postgresql/rename_table_test.rb
--- rails-4.1.8/activerecord/test/cases/adapters/postgresql/rename_table_test.rb	1969-12-31 21:00:00.000000000 -0300
+++ rails-4.1.10/activerecord/test/cases/adapters/postgresql/rename_table_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -0,0 +1,34 @@
+require "cases/helper"
+
+class PostgresqlRenameTableTest < ActiveRecord::TestCase
+  def setup
+    @connection = ActiveRecord::Base.connection
+    @connection.create_table :before_rename, force: true
+  end
+
+  def teardown
+    @connection.execute 'DROP TABLE IF EXISTS "before_rename"'
+    @connection.execute 'DROP TABLE IF EXISTS "after_rename"'
+  end
+
+  test "renaming a table also renames the primary key index" do
+    # sanity check
+    assert_equal 1, num_indices_named("before_rename_pkey")
+    assert_equal 0, num_indices_named("after_rename_pkey")
+
+    @connection.rename_table :before_rename, :after_rename
+
+    assert_equal 0, num_indices_named("before_rename_pkey")
+    assert_equal 1, num_indices_named("after_rename_pkey")
+  end
+
+  private
+
+  def num_indices_named(name)
+    @connection.execute(<<-SQL).values.length
+      SELECT 1 FROM "pg_index"
+        JOIN "pg_class" ON "pg_index"."indexrelid" = "pg_class"."oid"
+        WHERE "pg_class"."relname" = '#{name}'
+    SQL
+  end
+end
diff -Nru rails-4.1.8/activerecord/test/cases/adapters/postgresql/schema_test.rb rails-4.1.10/activerecord/test/cases/adapters/postgresql/schema_test.rb
--- rails-4.1.8/activerecord/test/cases/adapters/postgresql/schema_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/adapters/postgresql/schema_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -129,7 +129,7 @@
     SQL
 
     song = Song.create
-    album = Album.create
+    Album.create
     assert_equal song, Song.includes(:albums).references(:albums).first
   ensure
     ActiveRecord::Base.connection.execute "DROP SCHEMA music CASCADE;"
diff -Nru rails-4.1.8/activerecord/test/cases/adapter_test.rb rails-4.1.10/activerecord/test/cases/adapter_test.rb
--- rails-4.1.8/activerecord/test/cases/adapter_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/adapter_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -1,3 +1,5 @@
+# encoding: utf-8
+
 require "cases/helper"
 require "models/book"
 require "models/post"
@@ -205,6 +207,16 @@
     test "type_to_sql returns a String for unmapped types" do
       assert_equal "special_db_type", @connection.type_to_sql(:special_db_type)
     end
+
+    unless current_adapter?(:PostgreSQLAdapter)
+      def test_log_invalid_encoding
+        assert_raise ActiveRecord::StatementInvalid do
+          @connection.send :log, "SELECT 'ы' FROM DUAL" do
+            raise 'ы'.force_encoding(Encoding::ASCII_8BIT)
+          end
+        end
+      end
+    end
   end
 
   class AdapterTestWithoutTransaction < ActiveRecord::TestCase
diff -Nru rails-4.1.8/activerecord/test/cases/associations/eager_test.rb rails-4.1.10/activerecord/test/cases/associations/eager_test.rb
--- rails-4.1.8/activerecord/test/cases/associations/eager_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/associations/eager_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -269,6 +269,14 @@
     end
   end
 
+  def test_three_level_nested_preloading_does_not_raise_exception_when_association_does_not_exist
+    post_id = Comment.where(author_id: nil).where.not(post_id: nil).first.post_id
+
+    assert_nothing_raised do
+      Post.preload(:comments => [{:author => :essays}]).find(post_id)
+    end
+  end
+
   def test_nested_loading_through_has_one_association
     aa = AuthorAddress.all.merge!(:includes => {:author => :posts}).find(author_addresses(:david_address).id)
     assert_equal aa.author.posts.count, aa.author.posts.length
diff -Nru rails-4.1.8/activerecord/test/cases/associations/has_many_associations_test.rb rails-4.1.10/activerecord/test/cases/associations/has_many_associations_test.rb
--- rails-4.1.8/activerecord/test/cases/associations/has_many_associations_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/associations/has_many_associations_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -27,6 +27,8 @@
 require 'models/reference'
 require 'models/job'
 require 'models/tyre'
+require 'models/zine'
+require 'models/interest'
 
 class HasManyAssociationsTestForReorderWithJoinDependency < ActiveRecord::TestCase
   fixtures :authors, :posts, :comments
@@ -44,7 +46,7 @@
   fixtures :accounts, :categories, :companies, :developers, :projects,
            :developers_projects, :topics, :authors, :comments,
            :people, :posts, :readers, :taggings, :cars, :essays,
-           :categorizations, :jobs
+           :categorizations, :jobs, :zines, :interests
 
   def setup
     Client.destroyed_client_ids.clear
@@ -337,6 +339,45 @@
     assert_equal companies(:another_first_firm_client), companies(:first_firm).clients_sorted_desc.find_by_type('Client')
   end
 
+  def test_taking
+    posts(:other_by_bob).destroy
+    assert_equal posts(:misc_by_bob), authors(:bob).posts.take
+    assert_equal posts(:misc_by_bob), authors(:bob).posts.take!
+    authors(:bob).posts.to_a
+    assert_equal posts(:misc_by_bob), authors(:bob).posts.take
+    assert_equal posts(:misc_by_bob), authors(:bob).posts.take!
+  end
+
+  def test_taking_not_found
+    authors(:bob).posts.delete_all
+    assert_raise(ActiveRecord::RecordNotFound) { authors(:bob).posts.take! }
+    authors(:bob).posts.to_a
+    assert_raise(ActiveRecord::RecordNotFound) { authors(:bob).posts.take! }
+  end
+
+  def test_taking_with_a_number
+    # taking from unloaded Relation
+    bob = Author.find(authors(:bob).id)
+    assert_equal [posts(:misc_by_bob)], bob.posts.take(1)
+    bob = Author.find(authors(:bob).id)
+    assert_equal [posts(:misc_by_bob), posts(:other_by_bob)], bob.posts.take(2)
+
+    # taking from loaded Relation
+    bob.posts.to_a
+    assert_equal [posts(:misc_by_bob)], authors(:bob).posts.take(1)
+    assert_equal [posts(:misc_by_bob), posts(:other_by_bob)], authors(:bob).posts.take(2)
+  end
+
+  def test_taking_with_inverse_of
+    interests(:woodsmanship).destroy
+    interests(:survival).destroy
+
+    zine = zines(:going_out)
+    interest = zine.interests.take
+    assert_equal interests(:hunting), interest
+    assert_same zine, interest.zine
+  end
+
   def test_cant_save_has_many_readonly_association
     authors(:david).readonly_comments.each { |c| assert_raise(ActiveRecord::ReadOnlyRecord) { c.save! } }
     authors(:david).readonly_comments.each { |c| assert c.readonly? }
@@ -366,6 +407,13 @@
     assert_equal "Summit", Firm.all.merge!(:order => "id").first.clients_using_primary_key.first.name
   end
 
+  def test_update_all_on_association_accessed_before_save
+    firm = Firm.new(name: 'Firm')
+    firm.clients << Client.first
+    firm.save!
+    assert_equal firm.clients.count, firm.clients.update_all(description: 'Great!')
+  end
+
   def test_belongs_to_sanity
     c = Client.new
     assert_nil c.firm, "belongs_to failed sanity check on new object"
@@ -1827,6 +1875,14 @@
     assert_equal [bulb1, bulb2], car.all_bulbs.sort_by(&:id)
   end
 
+  test 'unscopes the default scope of associated model when used with include' do
+    car = Car.create!
+    bulb = Bulb.create! name: "other", car: car
+
+    assert_equal bulb, Car.find(car.id).all_bulbs.first
+    assert_equal bulb, Car.includes(:all_bulbs).find(car.id).all_bulbs.first
+  end
+
   test "raises RecordNotDestroyed when replaced child can't be destroyed" do
     car = Car.create!
     original_child = FailedBulb.create!(car: car)
diff -Nru rails-4.1.8/activerecord/test/cases/associations/has_many_through_associations_test.rb rails-4.1.10/activerecord/test/cases/associations/has_many_through_associations_test.rb
--- rails-4.1.8/activerecord/test/cases/associations/has_many_through_associations_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/associations/has_many_through_associations_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -24,12 +24,13 @@
 require 'models/member'
 require 'models/membership'
 require 'models/club'
+require 'models/organization'
 
 class HasManyThroughAssociationsTest < ActiveRecord::TestCase
   fixtures :posts, :readers, :people, :comments, :authors, :categories, :taggings, :tags,
            :owners, :pets, :toys, :jobs, :references, :companies, :members, :author_addresses,
            :subscribers, :books, :subscriptions, :developers, :categorizations, :essays,
-           :categories_posts, :clubs, :memberships
+           :categories_posts, :clubs, :memberships, :organizations
 
   # Dummies to force column loads so query counts are clean.
   def setup
@@ -1150,4 +1151,69 @@
     club.members << member
     assert_equal 1, SuperMembership.where(member_id: member.id, club_id: club.id).count
   end
+
+  def test_build_for_has_many_through_association
+    organization = organizations(:nsa)
+    author = organization.author
+    post_direct = author.posts.build
+    post_through = organization.posts.build
+    assert_equal post_direct.author_id, post_through.author_id
+  end
+end
+
+class NonTransactionalHMTAssociationsTest < ActiveRecord::TestCase
+  self.use_transactional_fixtures = false
+
+  class Shout < ActiveRecord::Base
+    self.table_name = "test_poly_shouts"
+
+    belongs_to :account
+    belongs_to :content, :polymorphic => true
+  end
+
+  class TextShout < ActiveRecord::Base
+    self.table_name = "test_poly_text_shouts"
+  end
+
+  class PictureShout < ActiveRecord::Base
+    self.table_name = "test_poly_picture_shouts"
+  end
+
+  class Account < ActiveRecord::Base
+    self.table_name = "test_poly_accounts"
+    has_many :shouts
+    has_many :text_shouts, :through => :shouts, :source => :content, :source_type => TextShout
+    has_many :picture_shouts, :through => :shouts, :source => :content, :source_type => PictureShout
+  end
+
+  def test_eager_load_polymorphic_nested_associations
+    @connection = ActiveRecord::Base.connection
+    @connection.create_table(:test_poly_accounts, force: true)
+    @connection.create_table(:test_poly_shouts, force: true) do |t|
+      t.references :account
+      t.references :content, polymorphic: true
+    end
+    @connection.create_table(:test_poly_text_shouts, force: true) do |t|
+      t.text :text
+    end
+    @connection.create_table(:test_poly_picture_shouts, force: true) do |t|
+      t.text :url
+    end
+
+    account = Account.create!
+
+    text_shout = TextShout.new(:text => "Hello")
+    picture_shout = PictureShout.new(:url => "some url")
+
+    account.shouts.create! :content => text_shout
+    account.shouts.create! :content => picture_shout
+
+    assert_includes Account.eager_load(:text_shouts, :picture_shouts).where("test_poly_text_shouts.text like '%Hello%'"), account
+    assert_includes Account.eager_load(:text_shouts, :picture_shouts).where("test_poly_picture_shouts.url like '%some%'"), account
+  ensure
+    @connection.execute("DROP TABLE IF EXISTS test_poly_accounts")
+    @connection.execute("DROP TABLE IF EXISTS test_poly_shouts")
+    @connection.execute("DROP TABLE IF EXISTS test_poly_text_shouts")
+    @connection.execute("DROP TABLE IF EXISTS test_poly_picture_shouts")
+  end
 end
diff -Nru rails-4.1.8/activerecord/test/cases/associations/inverse_associations_test.rb rails-4.1.10/activerecord/test/cases/associations/inverse_associations_test.rb
--- rails-4.1.8/activerecord/test/cases/associations/inverse_associations_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/associations/inverse_associations_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -10,6 +10,9 @@
 require 'models/car'
 require 'models/bulb'
 require 'models/mixed_case_monkey'
+require 'models/admin'
+require 'models/admin/account'
+require 'models/admin/user'
 
 class AutomaticInverseFindingTests < ActiveRecord::TestCase
   fixtures :ratings, :comments, :cars
@@ -27,6 +30,15 @@
     assert_equal monkey_reflection, man_reflection.inverse_of, "The man reflection's inverse should be the monkey reflection"
   end
 
+  def test_has_many_and_belongs_to_should_find_inverse_automatically_for_model_in_module
+    account_reflection = Admin::Account.reflect_on_association(:users)
+    user_reflection = Admin::User.reflect_on_association(:account)
+
+    assert_respond_to account_reflection, :has_inverse?
+    assert account_reflection.has_inverse?, "The Admin::Account reflection should have an inverse"
+    assert_equal user_reflection, account_reflection.inverse_of, "The Admin::Account reflection's inverse should be the Admin::User reflection"
+  end
+
   def test_has_one_and_belongs_to_should_find_inverse_automatically
     car_reflection = Car.reflect_on_association(:bulb)
     bulb_reflection = Bulb.reflect_on_association(:car)
diff -Nru rails-4.1.8/activerecord/test/cases/batches_test.rb rails-4.1.10/activerecord/test/cases/batches_test.rb
--- rails-4.1.8/activerecord/test/cases/batches_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/batches_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -106,6 +106,15 @@
     end
   end
 
+  def test_find_in_batches_should_ignore_reverse_order
+    ids = []
+    Post.select(:id).reverse_order.find_in_batches(:batch_size => 2) do |batch|
+      ids.concat batch.map(&:id)
+    end
+
+    assert_equal ids, Post.all.map(&:id)
+  end
+
   def test_find_in_batches_shouldnt_execute_query_unless_needed
     assert_queries(2) do
       Post.find_in_batches(:batch_size => @total) {|batch| assert_kind_of Array, batch }
@@ -200,6 +209,12 @@
     end
   end
 
+  def test_find_in_batches_enumerator_should_ignore_reverse_order
+    enum = Post.select(:id).reverse_order.find_in_batches(:batch_size => 2)
+
+    assert_equal enum.first(2).flatten.map(&:id), Post.limit(4).map(&:id)
+  end
+
   if Enumerator.method_defined? :size
     def test_find_in_batches_should_return_a_sized_enumerator
       assert_equal 11, Post.find_in_batches(:batch_size => 1).size
diff -Nru rails-4.1.8/activerecord/test/cases/dirty_test.rb rails-4.1.10/activerecord/test/cases/dirty_test.rb
--- rails-4.1.8/activerecord/test/cases/dirty_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/dirty_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -4,6 +4,7 @@
 require 'models/parrot'
 require 'models/person'   # For optimistic locking
 require 'models/aircraft'
+require 'models/binary'
 
 class Pirate # Just reopening it, not defining it
   attr_accessor :detected_changes_in_after_update # Boolean for if changes are detected
@@ -261,6 +262,14 @@
     assert_empty data.changes
   end
 
+  def test_binary_with_null_byte_with_same_value_not_marked_as_changed
+    binary = Binary.create!(data: "\\\\foo\x00\\\\bar")
+
+    binary.data = "\\\\foo\x00\\\\bar"
+
+    assert_not binary.changed?, "should be unchanged"
+  end
+
   def test_zero_to_blank_marked_as_changed
     pirate = Pirate.new
     pirate.catchphrase = "Yarrrr, me hearties"
diff -Nru rails-4.1.8/activerecord/test/cases/finder_test.rb rails-4.1.10/activerecord/test/cases/finder_test.rb
--- rails-4.1.8/activerecord/test/cases/finder_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/finder_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -34,10 +34,10 @@
   end
 
   def test_find_with_proc_parameter_and_block
-    e = assert_raises(RuntimeError) do
+    error = assert_raises(RuntimeError) do
       Topic.all.find(-> { raise "should happen" }) { |e| e.title == "non-existing-title" }
     end
-    assert_equal "should happen", e.message
+    assert_equal "should happen", error.message
 
     assert_nothing_raised(RuntimeError) do
       Topic.all.find(-> { raise "should not happen" }) { |e| e.title == topics(:first).title }
diff -Nru rails-4.1.8/activerecord/test/cases/fixtures_test.rb rails-4.1.10/activerecord/test/cases/fixtures_test.rb
--- rails-4.1.8/activerecord/test/cases/fixtures_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/fixtures_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -5,6 +5,7 @@
 require 'models/admin/user'
 require 'models/binary'
 require 'models/book'
+require 'models/bulb'
 require 'models/category'
 require 'models/company'
 require 'models/computer'
@@ -863,3 +864,16 @@
     assert_equal 'randomly_named_table', Admin::ClassNameThatDoesNotFollowCONVENTIONS.table_name
   end
 end
+
+class FixturesWithDefaultScopeTest < ActiveRecord::TestCase
+  fixtures :bulbs
+
+  test "inserts fixtures excluded by a default scope" do
+    assert_equal 1, Bulb.count
+    assert_equal 2, Bulb.unscoped.count
+  end
+
+  test "allows access to fixtures excluded by a default scope" do
+    assert_equal "special", bulbs(:special).name
+  end
+end
diff -Nru rails-4.1.8/activerecord/test/cases/inheritance_test.rb rails-4.1.10/activerecord/test/cases/inheritance_test.rb
--- rails-4.1.8/activerecord/test/cases/inheritance_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/inheritance_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -129,6 +129,12 @@
     assert_kind_of Cabbage, cabbage
   end
 
+  def test_becomes_and_change_tracking_for_inheritance_columns
+    cucumber = Vegetable.find(1)
+    cabbage = cucumber.becomes!(Cabbage)
+    assert_equal ['Cucumber', 'Cabbage'], cabbage.custom_type_change
+  end
+
   def test_alt_becomes_bang_resets_inheritance_type_column
     vegetable = Vegetable.create!(name: "Red Pepper")
     assert_nil vegetable.custom_type
diff -Nru rails-4.1.8/activerecord/test/cases/migration/change_table_test.rb rails-4.1.10/activerecord/test/cases/migration/change_table_test.rb
--- rails-4.1.8/activerecord/test/cases/migration/change_table_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/migration/change_table_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -74,8 +74,8 @@
 
       def test_timestamps_creates_updated_at_and_created_at
         with_change_table do |t|
-          @connection.expect :add_timestamps, nil, [:delete_me]
-          t.timestamps
+          @connection.expect :add_timestamps, nil, [:delete_me, {null: false}]
+          t.timestamps null: false
         end
       end
 
diff -Nru rails-4.1.8/activerecord/test/cases/reaper_test.rb rails-4.1.10/activerecord/test/cases/reaper_test.rb
--- rails-4.1.8/activerecord/test/cases/reaper_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/reaper_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -61,7 +61,7 @@
 
       def test_connection_pool_starts_reaper
         spec = ActiveRecord::Base.connection_pool.spec.dup
-        spec.config[:reaping_frequency] = 0.0001
+        spec.config[:reaping_frequency] = '0.0001'
 
         pool = ConnectionPool.new spec
         pool.dead_connection_timeout = 0
diff -Nru rails-4.1.8/activerecord/test/cases/relation/merging_test.rb rails-4.1.10/activerecord/test/cases/relation/merging_test.rb
--- rails-4.1.8/activerecord/test/cases/relation/merging_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/relation/merging_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -174,7 +174,7 @@
     rating_1 = comment_1.ratings.create!
 
     comment_2 = dev.comments.create!(body: "I'm John", post: Post.first)
-    rating_2 = comment_2.ratings.create!
+    comment_2.ratings.create!
 
     assert_equal dev.ratings, [rating_1]
   end
diff -Nru rails-4.1.8/activerecord/test/cases/relation/mutation_test.rb rails-4.1.10/activerecord/test/cases/relation/mutation_test.rb
--- rails-4.1.8/activerecord/test/cases/relation/mutation_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/relation/mutation_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -18,6 +18,10 @@
       def attribute_alias?(name)
         false
       end
+
+      def sanitize_sql(sql)
+        sql
+      end
     end
 
     def relation
@@ -95,11 +99,11 @@
     end
 
     test '#reorder!' do
-      relation = self.relation.order('foo')
+      order_relation = self.relation.order('foo')
 
-      assert relation.reorder!('bar').equal?(relation)
-      assert_equal ['bar'], relation.order_values
-      assert relation.reordering_value
+      assert order_relation.reorder!('bar').equal?(order_relation)
+      assert_equal ['bar'], order_relation.order_values
+      assert order_relation.reordering_value
     end
 
     test '#reorder! with symbol prepends the table name' do
diff -Nru rails-4.1.8/activerecord/test/cases/relation/where_test.rb rails-4.1.10/activerecord/test/cases/relation/where_test.rb
--- rails-4.1.8/activerecord/test/cases/relation/where_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/relation/where_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -1,15 +1,20 @@
 require "cases/helper"
-require 'models/author'
-require 'models/price_estimate'
-require 'models/treasure'
-require 'models/post'
-require 'models/comment'
-require 'models/edge'
-require 'models/topic'
+require "models/author"
+require "models/binary"
+require "models/cake_designer"
+require "models/chef"
+require "models/comment"
+require "models/edge"
+require "models/essay"
+require "models/post"
+require "models/price_estimate"
+require "models/topic"
+require "models/treasure"
+require "models/vertex"
 
 module ActiveRecord
   class WhereTest < ActiveRecord::TestCase
-    fixtures :posts, :edges, :authors
+    fixtures :posts, :edges, :authors, :binaries, :essays
 
     def test_where_copies_bind_params
       author = authors(:david)
@@ -188,5 +193,40 @@
         assert_equal 4, Edge.where(blank).order("sink_id").to_a.size
       end
     end
+
+    def test_where_on_association_with_custom_primary_key
+      author = authors(:david)
+      essay = Essay.where(writer: author).first
+
+      assert_equal essays(:david_modest_proposal), essay
+    end
+
+    def test_where_on_association_with_custom_primary_key_with_relation
+      author = authors(:david)
+      essay = Essay.where(writer: Author.where(id: author.id)).first
+
+      assert_equal essays(:david_modest_proposal), essay
+    end
+
+    def test_where_on_association_with_relation_performs_subselect_not_two_queries
+      author = authors(:david)
+
+      assert_queries(1) do
+        Essay.where(writer: Author.where(id: author.id)).to_a
+      end
+    end
+
+    def test_where_on_association_with_custom_primary_key_with_array_of_base
+      author = authors(:david)
+      essay = Essay.where(writer: [author]).first
+
+      assert_equal essays(:david_modest_proposal), essay
+    end
+
+    def test_where_on_association_with_custom_primary_key_with_array_of_ids
+      essay = Essay.where(writer: ["David"]).first
+
+      assert_equal essays(:david_modest_proposal), essay
+    end
   end
 end
diff -Nru rails-4.1.8/activerecord/test/cases/relations_test.rb rails-4.1.10/activerecord/test/cases/relations_test.rb
--- rails-4.1.8/activerecord/test/cases/relations_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/relations_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -15,6 +15,7 @@
 require 'models/tyre'
 require 'models/minivan'
 require 'models/aircraft'
+require "models/possession"
 
 
 class RelationTest < ActiveRecord::TestCase
@@ -396,6 +397,11 @@
     assert_equal        nil, ac.engines.maximum(:id)
   end
 
+  def test_null_relation_in_where_condition
+    assert_operator 0, :<, Comment.count # precondition, make sure there are comments.
+    assert_equal 0, Comment.where(post_id: Post.none).to_a.size
+  end
+
   def test_joins_with_nil_argument
     assert_nothing_raised { DependentFirm.joins(nil).first }
   end
@@ -1405,6 +1411,10 @@
     assert_equal [], scope.having_values
   end
 
+  def test_grouping_by_column_with_reserved_name
+    assert_equal [], Possession.select(:where).group(:where).to_a
+  end
+
   def test_references_triggers_eager_loading
     scope = Post.includes(:comments)
     assert !scope.eager_loading?
diff -Nru rails-4.1.8/activerecord/test/cases/transaction_callbacks_test.rb rails-4.1.10/activerecord/test/cases/transaction_callbacks_test.rb
--- rails-4.1.8/activerecord/test/cases/transaction_callbacks_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/transaction_callbacks_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -295,10 +295,14 @@
 
   def test_after_rollback_callbacks_should_validate_on_condition
     assert_raise(ArgumentError) { Topic.after_rollback(on: :save) }
+    e = assert_raise(ArgumentError) { Topic.after_rollback(on: 'create') }
+    assert_match(/:on conditions for after_commit and after_rollback callbacks have to be one of \[:create, :destroy, :update\]/, e.message)
   end
 
   def test_after_commit_callbacks_should_validate_on_condition
     assert_raise(ArgumentError) { Topic.after_commit(on: :save) }
+    e = assert_raise(ArgumentError) { Topic.after_commit(on: 'create') }
+    assert_match(/:on conditions for after_commit and after_rollback callbacks have to be one of \[:create, :destroy, :update\]/, e.message)
   end
 
   def test_saving_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_call_callbacks_on_the_parent_object
diff -Nru rails-4.1.8/activerecord/test/cases/validations/uniqueness_validation_test.rb rails-4.1.10/activerecord/test/cases/validations/uniqueness_validation_test.rb
--- rails-4.1.8/activerecord/test/cases/validations/uniqueness_validation_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/cases/validations/uniqueness_validation_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -45,6 +45,11 @@
 
   repair_validations(Topic, Reply)
 
+  class ModelWithScopedValidationOnArray < ActiveRecord::Base
+    self.table_name = 'postgresql_arrays'
+    validates_uniqueness_of :name, scope: [:commission_by_quarter]
+  end
+
   def test_validate_uniqueness
     Topic.validates_uniqueness_of(:title)
 
@@ -83,6 +88,34 @@
     assert_equal ["has already been taken"], t2.errors[:title]
   end
 
+  def test_validates_uniqueness_with_nil_scope
+    old_validators = Topic._validators.deep_dup
+    old_callbacks = Topic._validate_callbacks.deep_dup
+    Topic.validates_uniqueness_of(:title, scope: :parent_id)
+
+    Topic.create!(title: "test 1", parent_id: nil)
+    topic = Topic.new(title: "test 1", parent_id: nil)
+
+    refute topic.valid?
+  ensure
+    Topic._validators = old_validators
+    Topic._validate_callbacks = old_callbacks
+  end
+
+  def test_validates_uniqueness_with_false_scope
+    old_validators = Topic._validators.deep_dup
+    old_callbacks = Topic._validate_callbacks.deep_dup
+    Topic.validates_uniqueness_of(:title, scope: [:parent_id, :approved])
+
+    Topic.create!(title: "test 1", parent_id: nil, approved: false)
+    topic = Topic.new(title: "test 1", parent_id: nil, approved: false)
+
+    refute topic.valid?
+  ensure
+    Topic._validators = old_validators
+    Topic._validate_callbacks = old_callbacks
+  end
+
   def test_validates_uniqueness_with_validates
     Topic.validates :title, :uniqueness => true
     Topic.create!('title' => 'abc')
@@ -388,6 +421,15 @@
       assert e2.errors[:nicknames].any?, "Should have errors for nicknames"
       assert_equal ["has already been taken"], e2.errors[:nicknames], "Should have uniqueness message for nicknames"
     end
+
+    def test_validate_uniqueness_scoped_to_array
+      record = ModelWithScopedValidationOnArray.new(
+        name: "Sheldon Cooper",
+        commission_by_quarter: [1, 2, 3]
+      )
+
+      assert_nothing_raised { record.valid? }
+    end
   end
 
   def test_validate_uniqueness_on_existing_relation
diff -Nru rails-4.1.8/activerecord/test/fixtures/bulbs.yml rails-4.1.10/activerecord/test/fixtures/bulbs.yml
--- rails-4.1.8/activerecord/test/fixtures/bulbs.yml	1969-12-31 21:00:00.000000000 -0300
+++ rails-4.1.10/activerecord/test/fixtures/bulbs.yml	2015-03-19 13:48:26.000000000 -0300
@@ -0,0 +1,5 @@
+defaulty:
+  name: defaulty
+
+special:
+  name: special
diff -Nru rails-4.1.8/activerecord/test/models/organization.rb rails-4.1.10/activerecord/test/models/organization.rb
--- rails-4.1.8/activerecord/test/models/organization.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/models/organization.rb	2015-03-19 13:48:26.000000000 -0300
@@ -8,5 +8,7 @@
   has_one :author, :primary_key => :name
   has_one :author_owned_essay_category, :through => :author, :source => :owned_essay_category
 
+  has_many :posts, :through => :author, :source => :posts
+
   scope :clubs, -> { from('clubs') }
 end
diff -Nru rails-4.1.8/activerecord/test/schema/postgresql_specific_schema.rb rails-4.1.10/activerecord/test/schema/postgresql_specific_schema.rb
--- rails-4.1.8/activerecord/test/schema/postgresql_specific_schema.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activerecord/test/schema/postgresql_specific_schema.rb	2015-03-19 13:48:26.000000000 -0300
@@ -62,7 +62,8 @@
   CREATE TABLE postgresql_arrays (
     id SERIAL PRIMARY KEY,
     commission_by_quarter INTEGER[],
-    nicknames TEXT[]
+    nicknames TEXT[],
+    name TEXT
   );
 _SQL
 
diff -Nru rails-4.1.8/activesupport/CHANGELOG.md rails-4.1.10/activesupport/CHANGELOG.md
--- rails-4.1.8/activesupport/CHANGELOG.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/CHANGELOG.md	2015-03-19 13:48:26.000000000 -0300
@@ -1,9 +1,59 @@
+## Rails 4.1.10 (March 19, 2015) ##
+
+*   Fixed a roundtrip problem with AS::SafeBuffer where primitive-like strings
+    will be dumped as primitives:
+
+    Before:
+
+       YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml  # => "Hello"
+       YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml   # => true
+       YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml  # => false
+       YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml      # => 1
+       YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml    # => 1.1
+
+     After:
+
+       YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml  # => "Hello"
+       YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml   # => "true"
+       YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml  # => "false"
+       YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml      # => "1"
+       YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml    # => "1.1"
+
+    *Godfrey Chan*
+
+*   Replace fixed `:en` with `I18n.default_locale` in `Duration#inspect`.
+
+    *Dominik Masur*
+
+*   Add missing time zone definitions for Russian Federation and sync them
+    with `zone.tab` file from tzdata version 2014j (latest).
+
+    *Andrey Novikov*
+
+
+## Rails 4.1.9 (January 6, 2015) ##
+
+*   No changes.
+
+
+## Rails 4.1.8 (November 16, 2014) ##
+
 *   `Method` objects now report themselves as not `duplicable?`. This allows
     hashes and arrays containing `Method` objects to be `deep_dup`ed.
 
     *Peter Jaros*
 
 
+## Rails 4.1.7.1 (November 19, 2014) ##
+
+*   No changes.
+
+
+## Rails 4.1.7 (October 29, 2014) ##
+
+*   No changes.
+
+
 ## Rails 4.1.6 (September 11, 2014) ##
 
 *   Fix DateTime comparison with DateTime::Infinity object.
diff -Nru rails-4.1.8/activesupport/lib/active_support/cache.rb rails-4.1.10/activesupport/lib/active_support/cache.rb
--- rails-4.1.8/activesupport/lib/active_support/cache.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/cache.rb	2015-03-19 13:48:26.000000000 -0300
@@ -624,7 +624,7 @@
       # Check if the entry is expired. The +expires_in+ parameter can override
       # the value set when the entry was created.
       def expired?
-        convert_version_4beta1_entry! if defined?(@value)
+        convert_version_4beta1_entry! if defined?(@v)
         @expires_in && @created_at + @expires_in <= Time.now.to_f
       end
 
diff -Nru rails-4.1.8/activesupport/lib/active_support/callbacks.rb rails-4.1.10/activesupport/lib/active_support/callbacks.rb
--- rails-4.1.8/activesupport/lib/active_support/callbacks.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/callbacks.rb	2015-03-19 13:48:26.000000000 -0300
@@ -117,24 +117,24 @@
       ENDING = End.new
 
       class Before
-        def self.build(next_callback, user_callback, user_conditions, chain_config, filter)
+        def self.build(callback_sequence, user_callback, user_conditions, chain_config, filter)
           halted_lambda = chain_config[:terminator]
 
           if chain_config.key?(:terminator) && user_conditions.any?
-            halting_and_conditional(next_callback, user_callback, user_conditions, halted_lambda, filter)
+            halting_and_conditional(callback_sequence, user_callback, user_conditions, halted_lambda, filter)
           elsif chain_config.key? :terminator
-            halting(next_callback, user_callback, halted_lambda, filter)
+            halting(callback_sequence, user_callback, halted_lambda, filter)
           elsif user_conditions.any?
-            conditional(next_callback, user_callback, user_conditions)
+            conditional(callback_sequence, user_callback, user_conditions)
           else
-            simple next_callback, user_callback
+            simple callback_sequence, user_callback
           end
         end
 
         private
 
-        def self.halting_and_conditional(next_callback, user_callback, user_conditions, halted_lambda, filter)
-          lambda { |env|
+        def self.halting_and_conditional(callback_sequence, user_callback, user_conditions, halted_lambda, filter)
+          callback_sequence.before do |env|
             target = env.target
             value  = env.value
             halted = env.halted
@@ -146,12 +146,13 @@
                 target.send :halted_callback_hook, filter
               end
             end
-            next_callback.call env
-          }
+
+            env
+          end
         end
 
-        def self.halting(next_callback, user_callback, halted_lambda, filter)
-          lambda { |env|
+        def self.halting(callback_sequence, user_callback, halted_lambda, filter)
+          callback_sequence.before do |env|
             target = env.target
             value  = env.value
             halted = env.halted
@@ -163,56 +164,58 @@
                 target.send :halted_callback_hook, filter
               end
             end
-            next_callback.call env
-          }
+
+            env
+          end
         end
 
-        def self.conditional(next_callback, user_callback, user_conditions)
-          lambda { |env|
+        def self.conditional(callback_sequence, user_callback, user_conditions)
+          callback_sequence.before do |env|
             target = env.target
             value  = env.value
 
             if user_conditions.all? { |c| c.call(target, value) }
               user_callback.call target, value
             end
-            next_callback.call env
-          }
+
+            env
+          end
         end
 
-        def self.simple(next_callback, user_callback)
-          lambda { |env|
+        def self.simple(callback_sequence, user_callback)
+          callback_sequence.before do |env|
             user_callback.call env.target, env.value
-            next_callback.call env
-          }
+
+            env
+          end
         end
       end
 
       class After
-        def self.build(next_callback, user_callback, user_conditions, chain_config)
+        def self.build(callback_sequence, user_callback, user_conditions, chain_config)
           if chain_config[:skip_after_callbacks_if_terminated]
             if chain_config.key?(:terminator) && user_conditions.any?
-              halting_and_conditional(next_callback, user_callback, user_conditions)
+              halting_and_conditional(callback_sequence, user_callback, user_conditions)
             elsif chain_config.key?(:terminator)
-              halting(next_callback, user_callback)
+              halting(callback_sequence, user_callback)
             elsif user_conditions.any?
-              conditional next_callback, user_callback, user_conditions
+              conditional callback_sequence, user_callback, user_conditions
             else
-              simple next_callback, user_callback
+              simple callback_sequence, user_callback
             end
           else
             if user_conditions.any?
-              conditional next_callback, user_callback, user_conditions
+              conditional callback_sequence, user_callback, user_conditions
             else
-              simple next_callback, user_callback
+              simple callback_sequence, user_callback
             end
           end
         end
 
         private
 
-        def self.halting_and_conditional(next_callback, user_callback, user_conditions)
-          lambda { |env|
-            env = next_callback.call env
+        def self.halting_and_conditional(callback_sequence, user_callback, user_conditions)
+          callback_sequence.after do |env|
             target = env.target
             value  = env.value
             halted = env.halted
@@ -220,117 +223,119 @@
             if !halted && user_conditions.all? { |c| c.call(target, value) }
               user_callback.call target, value
             end
+
             env
-          }
+          end
         end
 
-        def self.halting(next_callback, user_callback)
-          lambda { |env|
-            env = next_callback.call env
+        def self.halting(callback_sequence, user_callback)
+          callback_sequence.after do |env|
             unless env.halted
               user_callback.call env.target, env.value
             end
+
             env
-          }
+          end
         end
 
-        def self.conditional(next_callback, user_callback, user_conditions)
-          lambda { |env|
-            env = next_callback.call env
+        def self.conditional(callback_sequence, user_callback, user_conditions)
+          callback_sequence.after do |env|
             target = env.target
             value  = env.value
 
             if user_conditions.all? { |c| c.call(target, value) }
               user_callback.call target, value
             end
+
             env
-          }
+          end
         end
 
-        def self.simple(next_callback, user_callback)
-          lambda { |env|
-            env = next_callback.call env
+        def self.simple(callback_sequence, user_callback)
+          callback_sequence.after do |env|
             user_callback.call env.target, env.value
+
             env
-          }
+          end
         end
       end
 
       class Around
-        def self.build(next_callback, user_callback, user_conditions, chain_config)
+        def self.build(callback_sequence, user_callback, user_conditions, chain_config)
           if chain_config.key?(:terminator) && user_conditions.any?
-            halting_and_conditional(next_callback, user_callback, user_conditions)
+            halting_and_conditional(callback_sequence, user_callback, user_conditions)
           elsif chain_config.key? :terminator
-            halting(next_callback, user_callback)
+            halting(callback_sequence, user_callback)
           elsif user_conditions.any?
-            conditional(next_callback, user_callback, user_conditions)
+            conditional(callback_sequence, user_callback, user_conditions)
           else
-            simple(next_callback, user_callback)
+            simple(callback_sequence, user_callback)
           end
         end
 
         private
 
-        def self.halting_and_conditional(next_callback, user_callback, user_conditions)
-          lambda { |env|
+        def self.halting_and_conditional(callback_sequence, user_callback, user_conditions)
+          callback_sequence.around do |env, &run|
             target = env.target
             value  = env.value
             halted = env.halted
 
             if !halted && user_conditions.all? { |c| c.call(target, value) }
               user_callback.call(target, value) {
-                env = next_callback.call env
+                env = run.call env
                 env.value
               }
+
               env
             else
-              next_callback.call env
+              run.call env
             end
-          }
+          end
         end
 
-        def self.halting(next_callback, user_callback)
-          lambda { |env|
+        def self.halting(callback_sequence, user_callback)
+          callback_sequence.around do |env, &run|
             target = env.target
             value  = env.value
 
-            unless env.halted
+            if env.halted
+              run.call env
+            else
               user_callback.call(target, value) {
-                env = next_callback.call env
+                env = run.call env
                 env.value
               }
               env
-            else
-              next_callback.call env
             end
-          }
+          end
         end
 
-        def self.conditional(next_callback, user_callback, user_conditions)
-          lambda { |env|
+        def self.conditional(callback_sequence, user_callback, user_conditions)
+          callback_sequence.around do |env, &run|
             target = env.target
             value  = env.value
 
             if user_conditions.all? { |c| c.call(target, value) }
               user_callback.call(target, value) {
-                env = next_callback.call env
+                env = run.call env
                 env.value
               }
               env
             else
-              next_callback.call env
+              run.call env
             end
-          }
+          end
         end
 
-        def self.simple(next_callback, user_callback)
-          lambda { |env|
+        def self.simple(callback_sequence, user_callback)
+          callback_sequence.around do |env, &run|
             user_callback.call(env.target, env.value) {
-              env = next_callback.call env
+              env = run.call env
               env.value
             }
             env
-          }
+          end
         end
       end
     end
@@ -382,17 +387,17 @@
       end
 
       # Wraps code with filter
-      def apply(next_callback)
+      def apply(callback_sequence)
         user_conditions = conditions_lambdas
         user_callback = make_lambda @filter
 
         case kind
         when :before
-          Filters::Before.build(next_callback, user_callback, user_conditions, chain_config, @filter)
+          Filters::Before.build(callback_sequence, user_callback, user_conditions, chain_config, @filter)
         when :after
-          Filters::After.build(next_callback, user_callback, user_conditions, chain_config)
+          Filters::After.build(callback_sequence, user_callback, user_conditions, chain_config)
         when :around
-          Filters::Around.build(next_callback, user_callback, user_conditions, chain_config)
+          Filters::Around.build(callback_sequence, user_callback, user_conditions, chain_config)
         end
       end
 
@@ -464,6 +469,42 @@
       end
     end
 
+    # Execute before and after filters in a sequence instead of
+    # chaining them with nested lambda calls, see:
+    # https://github.com/rails/rails/issues/18011
+    class CallbackSequence
+      def initialize(&call)
+        @call = call
+        @before = []
+        @after = []
+      end
+
+      def before(&before)
+        @before.unshift(before)
+        self
+      end
+
+      def after(&after)
+        @after.push(after)
+        self
+      end
+
+      def around(&around)
+        CallbackSequence.new do |*args|
+          around.call(*args) {
+            self.call(*args)
+          }
+        end
+      end
+
+      def call(*args)
+        @before.each { |b| b.call(*args) }
+        value = @call.call(*args)
+        @after.each { |a| a.call(*args) }
+        value
+      end
+    end
+
     # An Array with a compile method.
     class CallbackChain #:nodoc:#
       include Enumerable
@@ -508,8 +549,9 @@
 
       def compile
         @callbacks || @mutex.synchronize do
-          @callbacks ||= @chain.reverse.inject(Filters::ENDING) do |chain, callback|
-            callback.apply chain
+          final_sequence = CallbackSequence.new { |env| Filters::ENDING.call(env) }
+          @callbacks ||= @chain.reverse.inject(final_sequence) do |callback_sequence, callback|
+            callback.apply callback_sequence
           end
         end
       end
diff -Nru rails-4.1.8/activesupport/lib/active_support/core_ext/string/filters.rb rails-4.1.10/activesupport/lib/active_support/core_ext/string/filters.rb
--- rails-4.1.8/activesupport/lib/active_support/core_ext/string/filters.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/core_ext/string/filters.rb	2015-03-19 13:48:26.000000000 -0300
@@ -3,7 +3,7 @@
   # the string, and then changing remaining consecutive whitespace
   # groups into one space each.
   #
-  # Note that it handles both ASCII and Unicode whitespace like mongolian vowel separator (U+180E).
+  # Note that it handles both ASCII and Unicode whitespace.
   #
   #   %{ Multi-line
   #      string }.squish                   # => "Multi-line string"
diff -Nru rails-4.1.8/activesupport/lib/active_support/core_ext/string/output_safety.rb rails-4.1.10/activesupport/lib/active_support/core_ext/string/output_safety.rb
--- rails-4.1.8/activesupport/lib/active_support/core_ext/string/output_safety.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/core_ext/string/output_safety.rb	2015-03-19 13:48:26.000000000 -0300
@@ -142,7 +142,11 @@
       else
         if html_safe?
           new_safe_buffer = super
-          new_safe_buffer.instance_eval { @html_safe = true }
+
+          if new_safe_buffer
+            new_safe_buffer.instance_eval { @html_safe = true }
+          end
+
           new_safe_buffer
         else
           to_str[*args]
@@ -206,7 +210,7 @@
     end
 
     def encode_with(coder)
-      coder.represent_scalar nil, to_str
+      coder.represent_object nil, to_str
     end
 
     UNSAFE_STRING_METHODS.each do |unsafe_method|
diff -Nru rails-4.1.8/activesupport/lib/active_support/core_ext/time/zones.rb rails-4.1.10/activesupport/lib/active_support/core_ext/time/zones.rb
--- rails-4.1.8/activesupport/lib/active_support/core_ext/time/zones.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/core_ext/time/zones.rb	2015-03-19 13:48:26.000000000 -0300
@@ -1,4 +1,5 @@
 require 'active_support/time_with_zone'
+require 'active_support/core_ext/time/acts_like'
 require 'active_support/core_ext/date_and_time/zones'
 
 class Time
diff -Nru rails-4.1.8/activesupport/lib/active_support/duration.rb rails-4.1.10/activesupport/lib/active_support/duration.rb
--- rails-4.1.8/activesupport/lib/active_support/duration.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/duration.rb	2015-03-19 13:48:26.000000000 -0300
@@ -78,7 +78,7 @@
         reduce(::Hash.new(0)) { |h,(l,r)| h[l] += r; h }.
         sort_by {|unit,  _ | [:years, :months, :days, :minutes, :seconds].index(unit)}.
         map     {|unit, val| "#{val} #{val == 1 ? unit.to_s.chop : unit.to_s}"}.
-        to_sentence(:locale => :en)
+        to_sentence(locale: ::I18n.default_locale)
     end
 
     def as_json(options = nil) #:nodoc:
diff -Nru rails-4.1.8/activesupport/lib/active_support/gem_version.rb rails-4.1.10/activesupport/lib/active_support/gem_version.rb
--- rails-4.1.8/activesupport/lib/active_support/gem_version.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/gem_version.rb	2015-03-19 13:48:26.000000000 -0300
@@ -7,7 +7,7 @@
   module VERSION
     MAJOR = 4
     MINOR = 1
-    TINY  = 8
+    TINY  = 10
     PRE   = nil
 
     STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
diff -Nru rails-4.1.8/activesupport/lib/active_support/i18n_railtie.rb rails-4.1.10/activesupport/lib/active_support/i18n_railtie.rb
--- rails-4.1.8/activesupport/lib/active_support/i18n_railtie.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/i18n_railtie.rb	2015-03-19 13:48:26.000000000 -0300
@@ -36,7 +36,11 @@
       # Avoid issues with setting the default_locale by disabling available locales
       # check while configuring.
       enforce_available_locales = app.config.i18n.delete(:enforce_available_locales)
-      enforce_available_locales = I18n.enforce_available_locales unless I18n.enforce_available_locales.nil?
+
+      if enforce_available_locales.nil?
+        enforce_available_locales = I18n.enforce_available_locales
+      end
+
       I18n.enforce_available_locales = false
 
       app.config.i18n.each do |setting, value|
diff -Nru rails-4.1.8/activesupport/lib/active_support/multibyte/unicode.rb rails-4.1.10/activesupport/lib/active_support/multibyte/unicode.rb
--- rails-4.1.8/activesupport/lib/active_support/multibyte/unicode.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/multibyte/unicode.rb	2015-03-19 13:48:26.000000000 -0300
@@ -42,7 +42,6 @@
         0x0085,                # White_Space # Cc       <control-0085>
         0x00A0,                # White_Space # Zs       NO-BREAK SPACE
         0x1680,                # White_Space # Zs       OGHAM SPACE MARK
-        0x180E,                # White_Space # Zs       MONGOLIAN VOWEL SEPARATOR
         (0x2000..0x200A).to_a, # White_Space # Zs  [11] EN QUAD..HAIR SPACE
         0x2028,                # White_Space # Zl       LINE SEPARATOR
         0x2029,                # White_Space # Zp       PARAGRAPH SEPARATOR
diff -Nru rails-4.1.8/activesupport/lib/active_support/values/time_zone.rb rails-4.1.10/activesupport/lib/active_support/values/time_zone.rb
--- rails-4.1.8/activesupport/lib/active_support/values/time_zone.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/lib/active_support/values/time_zone.rb	2015-03-19 13:48:26.000000000 -0300
@@ -111,9 +111,11 @@
       "Jerusalem"                    => "Asia/Jerusalem",
       "Harare"                       => "Africa/Harare",
       "Pretoria"                     => "Africa/Johannesburg",
+      "Kaliningrad"                  => "Europe/Kaliningrad",
       "Moscow"                       => "Europe/Moscow",
       "St. Petersburg"               => "Europe/Moscow",
-      "Volgograd"                    => "Europe/Moscow",
+      "Volgograd"                    => "Europe/Volgograd",
+      "Samara"                       => "Europe/Samara",
       "Kuwait"                       => "Asia/Kuwait",
       "Riyadh"                       => "Asia/Riyadh",
       "Nairobi"                      => "Africa/Nairobi",
@@ -170,6 +172,7 @@
       "Guam"                         => "Pacific/Guam",
       "Port Moresby"                 => "Pacific/Port_Moresby",
       "Magadan"                      => "Asia/Magadan",
+      "Srednekolymsk"                => "Asia/Srednekolymsk",
       "Solomon Is."                  => "Pacific/Guadalcanal",
       "New Caledonia"                => "Pacific/Noumea",
       "Fiji"                         => "Pacific/Fiji",
diff -Nru rails-4.1.8/activesupport/test/caching_test.rb rails-4.1.10/activesupport/test/caching_test.rb
--- rails-4.1.8/activesupport/test/caching_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/test/caching_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -1065,7 +1065,7 @@
     version_4beta1_entry.instance_variable_set(:@v, "hello")
     version_4beta1_entry.instance_variable_set(:@x, Time.now.to_i - 1)
     entry = Marshal.load(Marshal.dump(version_4beta1_entry))
-    assert_equal "hello", entry.value
     assert_equal true, entry.expired?
+    assert_equal "hello", entry.value
   end
 end
diff -Nru rails-4.1.8/activesupport/test/core_ext/duration_test.rb rails-4.1.10/activesupport/test/core_ext/duration_test.rb
--- rails-4.1.8/activesupport/test/core_ext/duration_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/test/core_ext/duration_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -51,6 +51,15 @@
     assert_equal '14 days',                         1.fortnight.inspect
   end
 
+  def test_inspect_locale
+    current_locale = I18n.default_locale
+    I18n.default_locale = :de
+    I18n.backend.store_translations(:de, { support: { array: { last_word_connector: ' und ' } } })
+    assert_equal '10 years, 1 month und 1 day', (10.years + 1.month  + 1.day).inspect
+  ensure
+    I18n.default_locale = current_locale
+  end
+
   def test_minus_with_duration_does_not_break_subtraction_of_date_from_date
     assert_nothing_raised { Date.today - Date.today }
   end
diff -Nru rails-4.1.8/activesupport/test/core_ext/string_ext_test.rb rails-4.1.10/activesupport/test/core_ext/string_ext_test.rb
--- rails-4.1.8/activesupport/test/core_ext/string_ext_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/test/core_ext/string_ext_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -182,10 +182,10 @@
   end
 
   def test_string_squish
-    original = %{\u180E\u180E A string surrounded by unicode mongolian vowel separators,
-      with tabs(\t\t), newlines(\n\n), unicode nextlines(\u0085\u0085) and many spaces(  ). \u180E\u180E}
+    original = %{\u205f\u3000 A string surrounded by various unicode spaces,
+      with tabs(\t\t), newlines(\n\n), unicode nextlines(\u0085\u0085) and many spaces(  ). \u00a0\u2007}
 
-    expected = "A string surrounded by unicode mongolian vowel separators, " +
+    expected = "A string surrounded by various unicode spaces, " +
       "with tabs( ), newlines( ), unicode nextlines( ) and many spaces( )."
 
     # Make sure squish returns what we expect:
@@ -366,7 +366,7 @@
       now = Time.now
       assert_equal Time.local(now.year, now.month, now.day, 23, 50), "23:50".to_time
       assert_equal Time.utc(now.year, now.month, now.day, 23, 50), "23:50".to_time(:utc)
-      assert_equal Time.local(now.year, now.month, now.day, 18, 50), "13:50 -0100".to_time
+      assert_equal Time.local(now.year, now.month, now.day, 17, 50), "13:50 -0100".to_time
       assert_equal Time.utc(now.year, now.month, now.day, 23, 50), "22:50 -0100".to_time(:utc)
     end
   end
diff -Nru rails-4.1.8/activesupport/test/safe_buffer_test.rb rails-4.1.10/activesupport/test/safe_buffer_test.rb
--- rails-4.1.8/activesupport/test/safe_buffer_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/activesupport/test/safe_buffer_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -61,6 +61,13 @@
     assert_equal({'str' => str}, YAML.load(yaml))
   end
 
+  test "Should work with primitive-like-strings in to_yaml conversion" do
+    assert_equal 'true',  YAML.load(ActiveSupport::SafeBuffer.new('true').to_yaml)
+    assert_equal 'false', YAML.load(ActiveSupport::SafeBuffer.new('false').to_yaml)
+    assert_equal '1',     YAML.load(ActiveSupport::SafeBuffer.new('1').to_yaml)
+    assert_equal '1.1',   YAML.load(ActiveSupport::SafeBuffer.new('1.1').to_yaml)
+  end
+
   test "Should work with underscore" do
     str = "MyTest".html_safe.underscore
     assert_equal "my_test", str
@@ -165,4 +172,9 @@
     x = 'foo %{x} bar'.html_safe % { x: 'qux' }
     assert x.html_safe?, 'should be safe'
   end
+
+  test 'Should not affect frozen objects when accessing characters' do
+    x = 'Hello'.html_safe
+    assert_equal x[/a/, 1], nil
+  end
 end
diff -Nru rails-4.1.8/debian/changelog rails-4.1.10/debian/changelog
--- rails-4.1.8/debian/changelog	2014-11-25 16:51:56.000000000 -0200
+++ rails-4.1.10/debian/changelog	2015-04-03 18:25:30.000000000 -0300
@@ -1,3 +1,11 @@
+rails (2:4.1.10-1) UNRELEASED; urgency=medium
+
+  * New upstream release; bug fixes only
+  * debian/copyright: fix mention to the license of
+    guides/assets/javascripts/jquery.min.js
+
+ -- Antonio Terceiro <terceiro@debian.org>  Fri, 03 Apr 2015 18:19:36 -0300
+
 rails (2:4.1.8-1) unstable; urgency=medium
 
   * New upstream release
diff -Nru rails-4.1.8/debian/copyright rails-4.1.10/debian/copyright
--- rails-4.1.8/debian/copyright	2014-11-25 16:51:56.000000000 -0200
+++ rails-4.1.10/debian/copyright	2015-04-03 18:25:30.000000000 -0300
@@ -11,6 +11,11 @@
 Copyright: Copyright 2004-2013 David Heinemeier Hansson
 License: CC-BY-3.0
 
+Files: guides/assets/javascripts/jquery.min.js
+Copyright: Copyright 2011, John Resig
+ Copyright 2011, The Dojo Foundation
+License: Expat or BSD or GPL
+
 Files: guides/assets/javascripts/syntaxhighlighter/*.js
        guides/assets/stylesheets/syntaxhighlighter/*.css
 Copyright: 2004-2010 Alex Gorbatchev
@@ -400,3 +405,30 @@
      not granted under this License, such additional rights are deemed
      to be included in the License; this License is not intended to
      restrict the license of any rights under applicable law.
+
+License: BSD
+ All rights reserved.
+ .
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the University nor the names of its contributors
+    may be used to endorse or promote products derived from this software
+    without specific prior written permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
diff -Nru rails-4.1.8/Gemfile rails-4.1.10/Gemfile
--- rails-4.1.8/Gemfile	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/Gemfile	2015-03-19 13:48:26.000000000 -0300
@@ -25,7 +25,8 @@
   gem 'sdoc', '~> 0.4.0'
   gem 'redcarpet', '~> 2.2.2', platforms: :ruby
   gem 'w3c_validators'
-  gem 'kindlerb'
+  gem 'kindlerb', '0.1.1'
+  gem 'mustache', '~> 0.99.8'
 end
 
 # AS
diff -Nru rails-4.1.8/Gemfile.lock rails-4.1.10/Gemfile.lock
--- rails-4.1.8/Gemfile.lock	1969-12-31 21:00:00.000000000 -0300
+++ rails-4.1.10/Gemfile.lock	2015-03-19 13:48:26.000000000 -0300
@@ -0,0 +1,154 @@
+PATH
+  remote: .
+  specs:
+    actionmailer (4.1.10.rc1)
+      actionpack (= 4.1.10.rc1)
+      actionview (= 4.1.10.rc1)
+      mail (~> 2.5, >= 2.5.4)
+    actionpack (4.1.10.rc1)
+      actionview (= 4.1.10.rc1)
+      activesupport (= 4.1.10.rc1)
+      rack (~> 1.5.2)
+      rack-test (~> 0.6.2)
+    actionview (4.1.10.rc1)
+      activesupport (= 4.1.10.rc1)
+      builder (~> 3.1)
+      erubis (~> 2.7.0)
+    activemodel (4.1.10.rc1)
+      activesupport (= 4.1.10.rc1)
+      builder (~> 3.1)
+    activerecord (4.1.10.rc1)
+      activemodel (= 4.1.10.rc1)
+      activesupport (= 4.1.10.rc1)
+      arel (~> 5.0.0)
+    activesupport (4.1.10.rc1)
+      i18n (~> 0.6, >= 0.6.9)
+      json (~> 1.7, >= 1.7.7)
+      minitest (~> 5.1)
+      thread_safe (~> 0.1)
+      tzinfo (~> 1.1)
+    rails (4.1.10.rc1)
+      actionmailer (= 4.1.10.rc1)
+      actionpack (= 4.1.10.rc1)
+      actionview (= 4.1.10.rc1)
+      activemodel (= 4.1.10.rc1)
+      activerecord (= 4.1.10.rc1)
+      activesupport (= 4.1.10.rc1)
+      bundler (>= 1.3.0, < 2.0)
+      railties (= 4.1.10.rc1)
+      sprockets-rails (~> 2.0)
+    railties (4.1.10.rc1)
+      actionpack (= 4.1.10.rc1)
+      activesupport (= 4.1.10.rc1)
+      rake (>= 0.8.7)
+      thor (>= 0.18.1, < 2.0)
+
+GEM
+  remote: https://rubygems.org/
+  specs:
+    arel (5.0.1.20140414130214)
+    bcrypt (3.1.10)
+    benchmark-ips (2.1.1)
+    builder (3.2.2)
+    coffee-rails (4.0.1)
+      coffee-script (>= 2.2.0)
+      railties (>= 4.0.0, < 5.0)
+    coffee-script (2.3.0)
+      coffee-script-source
+      execjs
+    coffee-script-source (1.9.0)
+    dalli (2.7.2)
+    erubis (2.7.0)
+    execjs (2.3.0)
+    hike (1.2.3)
+    i18n (0.7.0)
+    jquery-rails (3.1.2)
+      railties (>= 3.0, < 5.0)
+      thor (>= 0.14, < 2.0)
+    json (1.8.2)
+    kindlerb (0.1.1)
+      mustache
+      nokogiri
+    mail (2.6.3)
+      mime-types (>= 1.16, < 3)
+    metaclass (0.0.4)
+    mime-types (2.4.3)
+    mini_portile (0.6.2)
+    minitest (5.3.3)
+    mocha (0.14.0)
+      metaclass (~> 0.0.1)
+    multi_json (1.10.1)
+    mustache (0.99.8)
+    mysql (2.9.1)
+    mysql2 (0.3.18)
+    nokogiri (1.6.6.2)
+      mini_portile (~> 0.6.0)
+    pg (0.18.1)
+    racc (1.4.12)
+    rack (1.5.2)
+    rack-cache (1.2)
+      rack (>= 0.4)
+    rack-test (0.6.3)
+      rack (>= 1.0)
+    rake (10.4.2)
+    rdoc (4.2.0)
+    redcarpet (2.2.2)
+    ruby-prof (0.11.3)
+    sdoc (0.4.1)
+      json (~> 1.7, >= 1.7.7)
+      rdoc (~> 4.0)
+    sprockets (2.12.3)
+      hike (~> 1.2)
+      multi_json (~> 1.0)
+      rack (~> 1.0)
+      tilt (~> 1.1, != 1.3.0)
+    sprockets-rails (2.2.4)
+      actionpack (>= 3.0)
+      activesupport (>= 3.0)
+      sprockets (>= 2.8, < 4.0)
+    sqlite3 (1.3.10)
+    thor (0.19.1)
+    thread_safe (0.3.4)
+    tilt (1.4.1)
+    turbolinks (2.5.3)
+      coffee-rails
+    tzinfo (1.2.2)
+      thread_safe (~> 0.1)
+    uglifier (2.7.0)
+      execjs (>= 0.3.0)
+      json (>= 1.8.0)
+    w3c_validators (1.2)
+      json
+      nokogiri
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  activerecord-jdbcmysql-adapter (>= 1.3.0)
+  activerecord-jdbcpostgresql-adapter (>= 1.3.0)
+  activerecord-jdbcsqlite3-adapter (>= 1.3.0)
+  bcrypt (~> 3.1.7)
+  benchmark-ips
+  coffee-rails (~> 4.0.0)
+  dalli (>= 2.2.1)
+  jquery-rails (~> 3.1.0)
+  json
+  kindlerb (= 0.1.1)
+  minitest (< 5.3.4)
+  mocha (~> 0.14)
+  mustache (~> 0.99.8)
+  mysql (>= 2.9.0)
+  mysql2 (>= 0.3.13)
+  nokogiri (>= 1.4.5)
+  pg (>= 0.11.0)
+  racc (>= 1.4.6)
+  rack-cache (~> 1.2)
+  rails!
+  redcarpet (~> 2.2.2)
+  ruby-prof (~> 0.11.2)
+  sdoc (~> 0.4.0)
+  sqlite3 (~> 1.3.6)
+  turbolinks
+  uglifier (>= 1.3.0)
+  w3c_validators
diff -Nru rails-4.1.8/.gitignore rails-4.1.10/.gitignore
--- rails-4.1.8/.gitignore	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/.gitignore	2015-03-19 13:48:26.000000000 -0300
@@ -5,7 +5,6 @@
 .Gemfile
 /.bundle
 /.ruby-version
-/Gemfile.lock
 pkg
 /dist
 /doc/rdoc
diff -Nru rails-4.1.8/guides/bug_report_templates/action_controller_gem.rb rails-4.1.10/guides/bug_report_templates/action_controller_gem.rb
--- rails-4.1.8/guides/bug_report_templates/action_controller_gem.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/guides/bug_report_templates/action_controller_gem.rb	2015-03-19 13:48:26.000000000 -0300
@@ -7,8 +7,8 @@
 class TestApp < Rails::Application
   config.root = File.dirname(__FILE__)
   config.session_store :cookie_store, key: 'cookie_store_key'
-  config.secret_token    = 'secret_token'
-  config.secret_key_base = 'secret_key_base'
+  secrets.secret_token    = 'secret_token'
+  secrets.secret_key_base = 'secret_key_base'
 
   config.logger = Logger.new($stdout)
   Rails.logger  = config.logger
diff -Nru rails-4.1.8/guides/bug_report_templates/action_controller_master.rb rails-4.1.10/guides/bug_report_templates/action_controller_master.rb
--- rails-4.1.8/guides/bug_report_templates/action_controller_master.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/guides/bug_report_templates/action_controller_master.rb	2015-03-19 13:48:26.000000000 -0300
@@ -16,8 +16,8 @@
 class TestApp < Rails::Application
   config.root = File.dirname(__FILE__)
   config.session_store :cookie_store, key: 'cookie_store_key'
-  config.secret_token    = 'secret_token'
-  config.secret_key_base = 'secret_key_base'
+  secrets.secret_token    = 'secret_token'
+  secrets.secret_key_base = 'secret_key_base'
 
   config.logger = Logger.new($stdout)
   Rails.logger  = config.logger
diff -Nru rails-4.1.8/guides/CHANGELOG.md rails-4.1.10/guides/CHANGELOG.md
--- rails-4.1.8/guides/CHANGELOG.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/guides/CHANGELOG.md	2015-03-19 13:48:26.000000000 -0300
@@ -1,3 +1,28 @@
+## Rails 4.1.10 (March 19, 2015) ##
+
+*   No changes.
+
+
+## Rails 4.1.9 (January 6, 2015) ##
+
+*   No changes.
+
+
+## Rails 4.1.8 (November 16, 2014) ##
+
+*   No changes.
+
+
+## Rails 4.1.7.1 (November 19, 2014) ##
+
+*   No changes.
+
+
+## Rails 4.1.7 (October 29, 2014) ##
+
+*   No changes.
+
+
 ## Rails 4.1.6 (September 11, 2014) ##
 
 *   No changes.
diff -Nru rails-4.1.8/guides/source/3_1_release_notes.md rails-4.1.10/guides/source/3_1_release_notes.md
--- rails-4.1.8/guides/source/3_1_release_notes.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/guides/source/3_1_release_notes.md	2015-03-19 13:48:26.000000000 -0300
@@ -169,7 +169,7 @@
 
 The major change in Rails 3.1 is the Assets Pipeline. It makes CSS and JavaScript first-class code citizens and enables proper organization, including use in plugins and engines.
 
-The assets pipeline is powered by [Sprockets](https://github.com/sstephenson/sprockets) and is covered in the [Asset Pipeline](asset_pipeline.html) guide.
+The assets pipeline is powered by [Sprockets](https://github.com/rails/sprockets) and is covered in the [Asset Pipeline](asset_pipeline.html) guide.
 
 ### HTTP Streaming
 
diff -Nru rails-4.1.8/guides/source/active_support_core_extensions.md rails-4.1.10/guides/source/active_support_core_extensions.md
--- rails-4.1.8/guides/source/active_support_core_extensions.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/guides/source/active_support_core_extensions.md	2015-03-19 13:48:26.000000000 -0300
@@ -1281,7 +1281,7 @@
 
 There's also the destructive version `String#squish!`.
 
-Note that it handles both ASCII and Unicode whitespace like mongolian vowel separator (U+180E).
+Note that it handles both ASCII and Unicode whitespace.
 
 NOTE: Defined in `active_support/core_ext/string/filters.rb`.
 
diff -Nru rails-4.1.8/guides/source/asset_pipeline.md rails-4.1.10/guides/source/asset_pipeline.md
--- rails-4.1.8/guides/source/asset_pipeline.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/guides/source/asset_pipeline.md	2015-03-19 13:48:26.000000000 -0300
@@ -208,7 +208,7 @@
 NOTE: You must have an ExecJS supported runtime in order to use CoffeeScript.
 If you are using Mac OS X or Windows, you have a JavaScript runtime installed in
 your operating system. Check
-[ExecJS](https://github.com/sstephenson/execjs#readme) documentation to know all
+[ExecJS](https://github.com/rails/execjs#readme) documentation to know all
 supported JavaScript runtimes.
 
 You can also disable generation of controller specific asset files by adding the
@@ -969,7 +969,7 @@
 config.assets.js_compressor = :uglifier
 ```
 
-NOTE: You will need an [ExecJS](https://github.com/sstephenson/execjs#readme)
+NOTE: You will need an [ExecJS](https://github.com/rails/execjs#readme)
 supported runtime in order to use `uglifier`. If you are using Mac OS X or
 Windows you have a JavaScript runtime installed in your operating system.
 
diff -Nru rails-4.1.8/guides/source/engines.md rails-4.1.10/guides/source/engines.md
--- rails-4.1.8/guides/source/engines.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/guides/source/engines.md	2015-03-19 13:48:26.000000000 -0300
@@ -590,11 +590,11 @@
 the comments, however, is not quite right yet. If you were to create a comment
 right now, you would see this error:
 
-``` 
+```
 Missing partial blorgh/comments/comment with {:handlers=>[:erb, :builder],
 :formats=>[:html], :locale=>[:en, :en]}. Searched in:   *
 "/Users/ryan/Sites/side_projects/blorgh/test/dummy/app/views"   *
-"/Users/ryan/Sites/side_projects/blorgh/app/views" 
+"/Users/ryan/Sites/side_projects/blorgh/app/views"
 ```
 
 The engine is unable to find the partial required for rendering the comments.
@@ -828,12 +828,12 @@
 Notice that only _one_ migration was copied over here. This is because the first
 two migrations were copied over the first time this command was run.
 
-``` 
+```
 NOTE Migration [timestamp]_create_blorgh_posts.rb from blorgh has been
 skipped. Migration with the same name already exists. NOTE Migration
 [timestamp]_create_blorgh_comments.rb from blorgh has been skipped. Migration
 with the same name already exists. Copied migration
-[timestamp]_add_author_id_to_blorgh_posts.rb from blorgh 
+[timestamp]_add_author_id_to_blorgh_posts.rb from blorgh
 ```
 
 Run the migration using:
@@ -1036,22 +1036,43 @@
 typical `GET` to a controller in a controller's functional test like this:
 
 ```ruby
-get :index
+module Blorgh
+  class FooControllerTest < ActionController::TestCase
+    def test_index
+      get :index
+      ...
+    end
+  end
+end
 ```
 
 It may not function correctly. This is because the application doesn't know how
 to route these requests to the engine unless you explicitly tell it **how**. To
-do this, you must also pass the `:use_route` option as a parameter on these
-requests:
+do this, you must set the `@routes` instance variable to the engine's route set
+in your setup code:
 
 ```ruby
-get :index, use_route: :blorgh
+module Blorgh
+  class FooControllerTest < ActionController::TestCase
+    setup do
+      @routes = Engine.routes
+    end
+
+    def test_index
+      get :index
+      ...
+    end
+  end
+end
 ```
 
 This tells the application that you still want to perform a `GET` request to the
 `index` action of this controller, but you want to use the engine's route to get
 there, rather than the application's one.
 
+This also ensures that the engine's URL helpers will work as expected in your
+tests.
+
 Improving engine functionality
 ------------------------------
 
diff -Nru rails-4.1.8/guides/source/getting_started.md rails-4.1.10/guides/source/getting_started.md
--- rails-4.1.8/guides/source/getting_started.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/guides/source/getting_started.md	2015-03-19 13:48:26.000000000 -0300
@@ -199,7 +199,7 @@
 uncomment if you need it. `therubyrhino` is the recommended runtime for JRuby
 users and is added by default to the `Gemfile` in apps generated under JRuby.
 You can investigate about all the supported runtimes at
-[ExecJS](https://github.com/sstephenson/execjs#readme).
+[ExecJS](https://github.com/rails/execjs#readme).
 
 This will fire up WEBrick, a web server distributed with Ruby by default. To see
 your application in action, open a browser window and navigate to
diff -Nru rails-4.1.8/guides/source/security.md rails-4.1.10/guides/source/security.md
--- rails-4.1.8/guides/source/security.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/guides/source/security.md	2015-03-19 13:48:26.000000000 -0300
@@ -356,7 +356,7 @@
 
 **CSRF** Cross-Site Request Forgery (CSRF), also known as Cross-Site Reference Forgery (XSRF), is a gigantic attack method, it allows the attacker to do everything the administrator or Intranet user may do. As you have already seen above how CSRF works, here are a few examples of what attackers can do in the Intranet or admin interface.
 
-A real-world example is a [router reconfiguration by CSRF](http://www.h-online.com/security/Symantec-reports-first-active-attack-on-a-DSL-router--/news/102352). The attackers sent a malicious e-mail, with CSRF in it, to Mexican users. The e-mail claimed there was an e-card waiting for them, but it also contained an image tag that resulted in a HTTP-GET request to reconfigure the user's router (which is a popular model in Mexico). The request changed the DNS-settings so that requests to a Mexico-based banking site would be mapped to the attacker's site. Everyone who accessed the banking site through that router saw the attacker's fake web site and had their credentials stolen.
+A real-world example is a [router reconfiguration by CSRF](http://www.h-online.com/security/news/item/Symantec-reports-first-active-attack-on-a-DSL-router-735883.html). The attackers sent a malicious e-mail, with CSRF in it, to Mexican users. The e-mail claimed there was an e-card waiting for them, but it also contained an image tag that resulted in a HTTP-GET request to reconfigure the user's router (which is a popular model in Mexico). The request changed the DNS-settings so that requests to a Mexico-based banking site would be mapped to the attacker's site. Everyone who accessed the banking site through that router saw the attacker's fake web site and had their credentials stolen.
 
 Another example changed Google Adsense's e-mail address and password by. If the victim was logged into Google Adsense, the administration interface for Google advertisements campaigns, an attacker could change their credentials.

 
diff -Nru rails-4.1.8/guides/source/testing.md rails-4.1.10/guides/source/testing.md
--- rails-4.1.8/guides/source/testing.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/guides/source/testing.md	2015-03-19 13:48:26.000000000 -0300
@@ -712,7 +712,7 @@
     https!(false)
     get "/posts/all"
     assert_response :success
-    assert assigns(:products)
+    assert assigns(:posts)
   end
 end
 ```
diff -Nru rails-4.1.8/guides/source/upgrading_ruby_on_rails.md rails-4.1.10/guides/source/upgrading_ruby_on_rails.md
--- rails-4.1.8/guides/source/upgrading_ruby_on_rails.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/guides/source/upgrading_ruby_on_rails.md	2015-03-19 13:48:26.000000000 -0300
@@ -541,7 +541,7 @@
 ```ruby
 # Require the gems listed in Gemfile, including any gems
 # you've limited to :test, :development, or :production.
-Bundler.require(:default, Rails.env)
+Bundler.require(*Rails.groups)
 ```
 
 ### vendor/plugins
diff -Nru rails-4.1.8/RAILS_VERSION rails-4.1.10/RAILS_VERSION
--- rails-4.1.8/RAILS_VERSION	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/RAILS_VERSION	2015-03-19 13:48:26.000000000 -0300
@@ -1 +1 @@
-4.1.8
+4.1.10
diff -Nru rails-4.1.8/railties/CHANGELOG.md rails-4.1.10/railties/CHANGELOG.md
--- rails-4.1.8/railties/CHANGELOG.md	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/CHANGELOG.md	2015-03-19 13:48:26.000000000 -0300
@@ -1,3 +1,40 @@
+## Rails 4.1.10 (March 19, 2015) ##
+
+*   Add a new-line to the end of route method generated code.
+
+    We need to add a `\n`, because we cannot have two routes
+    in the same line.
+
+    *arthurnn*
+
+*   Force generated routes to be inserted into routes.rb
+
+    *Andrew White*
+
+*   Don't remove all line endings from routes.rb when revoking scaffold.
+
+    Fixes #15913.
+
+    *Andrew White*
+
+*   Fix scaffold generator with `--helper=false` option.
+
+    *Rafael Mendonça França*
+
+
+## Rails 4.1.9 (January 6, 2015) ##
+
+*   No changes.
+
+
+## Rails 4.1.8 (November 16, 2014) ##
+
+*   `secret_token` is now saved in `Rails.application.secrets.secret_token`
+    and it falls back to the value of `config.secret_token` when it is not
+    present in `config/secrets.yml`.
+
+    *Benjamin Fleischer*
+
 *   Specify dummy app's db migrate path in plugin's test_helper.rb.
 
     Fixes #16877.
@@ -10,6 +47,16 @@
     *Yukio Mizuta*
 
 
+## Rails 4.1.7.1 (November 19, 2014) ##
+
+*   No changes.
+
+
+## Rails 4.1.7 (October 29, 2014) ##
+
+*   No changes.
+
+
 ## Rails 4.1.6 (September 11, 2014) ##
 
 *   Scaffold generator `_form` partial adds `class="field"` for password
diff -Nru rails-4.1.8/railties/lib/rails/application.rb rails-4.1.10/railties/lib/rails/application.rb
--- rails-4.1.8/railties/lib/rails/application.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/application.rb	2015-03-19 13:48:26.000000000 -0300
@@ -158,7 +158,7 @@
           key_generator = ActiveSupport::KeyGenerator.new(secrets.secret_key_base, iterations: 1000)
           ActiveSupport::CachingKeyGenerator.new(key_generator)
         else
-          ActiveSupport::LegacyKeyGenerator.new(config.secret_token)
+          ActiveSupport::LegacyKeyGenerator.new(secrets.secret_token)
         end
       end
     end
@@ -197,7 +197,7 @@
         super.merge({
           "action_dispatch.parameter_filter" => config.filter_parameters,
           "action_dispatch.redirect_filter" => config.filter_redirect,
-          "action_dispatch.secret_token" => config.secret_token,
+          "action_dispatch.secret_token" => secrets.secret_token,
           "action_dispatch.secret_key_base" => secrets.secret_key_base,
           "action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions,
           "action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local,
@@ -316,7 +316,21 @@
       @config = configuration
     end
 
-    def secrets #:nodoc:
+    # Returns secrets added to config/secrets.yml.
+    #
+    # Example:
+    #
+    #     development:
+    #       secret_key_base: 836fa3665997a860728bcb9e9a1e704d427cfc920e79d847d79c8a9a907b9e965defa4154b2b86bdec6930adbe33f21364523a6f6ce363865724549fdfc08553
+    #     test:
+    #       secret_key_base: 5a37811464e7d378488b0f073e2193b093682e4e21f5d6f3ae0a4e1781e61a351fdc878a843424e81c73fb484a40d23f92c8dafac4870e74ede6e5e174423010
+    #     production:
+    #       secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
+    #       namespace: my_app_production
+    #
+    # +Rails.application.secrets.namespace+ returns +my_app_production+ in the
+    # production environment.
+    def secrets
       @secrets ||= begin
         secrets = ActiveSupport::OrderedOptions.new
         yaml = config.paths["config/secrets"].first
@@ -329,6 +343,8 @@
 
         # Fallback to config.secret_key_base if secrets.secret_key_base isn't set
         secrets.secret_key_base ||= config.secret_key_base
+        # Fallback to config.secret_token if secrets.secret_token isn't set
+        secrets.secret_token ||= config.secret_token
 
         secrets
       end
@@ -458,8 +474,13 @@
     end
 
     def validate_secret_key_config! #:nodoc:
-      if secrets.secret_key_base.blank? && config.secret_token.blank?
-        raise "Missing `secret_key_base` for '#{Rails.env}' environment, set this value in `config/secrets.yml`"
+      if secrets.secret_key_base.blank?
+        ActiveSupport::Deprecation.warn "You didn't set `secret_key_base`. " +
+          "Read the upgrade documentation to learn more about this new config option."
+
+        if secrets.secret_token.blank?
+          raise "Missing `secret_token` and `secret_key_base` for '#{Rails.env}' environment, set these values in `config/secrets.yml`"
+        end
       end
     end
   end
diff -Nru rails-4.1.8/railties/lib/rails/engine.rb rails-4.1.10/railties/lib/rails/engine.rb
--- rails-4.1.8/railties/lib/rails/engine.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/engine.rb	2015-03-19 13:48:26.000000000 -0300
@@ -351,7 +351,7 @@
 
           base.called_from = begin
             call_stack = if Kernel.respond_to?(:caller_locations)
-              caller_locations.map(&:path)
+              caller_locations.map { |l| l.absolute_path || l.path }
             else
               # Remove the line number from backtraces making sure we don't leave anything behind
               caller.map { |p| p.sub(/:\d+.*/, '') }
@@ -567,10 +567,10 @@
     end
 
     initializer :add_routing_paths do |app|
-      paths = self.paths["config/routes.rb"].existent
+      routing_paths = self.paths["config/routes.rb"].existent
 
-      if routes? || paths.any?
-        app.routes_reloader.paths.unshift(*paths)
+      if routes? || routing_paths.any?
+        app.routes_reloader.paths.unshift(*routing_paths)
         app.routes_reloader.route_sets << routes
       end
     end
diff -Nru rails-4.1.8/railties/lib/rails/gem_version.rb rails-4.1.10/railties/lib/rails/gem_version.rb
--- rails-4.1.8/railties/lib/rails/gem_version.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/gem_version.rb	2015-03-19 13:48:26.000000000 -0300
@@ -7,7 +7,7 @@
   module VERSION
     MAJOR = 4
     MINOR = 1
-    TINY  = 8
+    TINY  = 10
     PRE   = nil
 
     STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
diff -Nru rails-4.1.8/railties/lib/rails/generators/actions.rb rails-4.1.10/railties/lib/rails/generators/actions.rb
--- rails-4.1.8/railties/lib/rails/generators/actions.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/actions.rb	2015-03-19 13:48:26.000000000 -0300
@@ -218,10 +218,10 @@
       #   route "root 'welcome#index'"
       def route(routing_code)
         log :route, routing_code
-        sentinel = /\.routes\.draw do\s*$/
+        sentinel = /\.routes\.draw do\s*\n/m
 
         in_root do
-          inject_into_file 'config/routes.rb', "\n  #{routing_code}", { after: sentinel, verbose: false }
+          inject_into_file 'config/routes.rb', "  #{routing_code}\n", { after: sentinel, verbose: false, force: true }
         end
       end
 
diff -Nru rails-4.1.8/railties/lib/rails/generators/app_base.rb rails-4.1.10/railties/lib/rails/generators/app_base.rb
--- rails-4.1.8/railties/lib/rails/generators/app_base.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/app_base.rb	2015-03-19 13:48:26.000000000 -0300
@@ -241,23 +241,14 @@
       def assets_gemfile_entry
         return [] if options[:skip_sprockets]
 
-        gems = []
-        if options.dev? || options.edge?
-          gems << GemfileEntry.github('sprockets-rails', 'rails/sprockets-rails', '2-1-stable',
-                                    'Use latest 2.1 version of sprockets-rails')
-          gems << GemfileEntry.github('sass-rails', 'rails/sass-rails', nil,
-                                    'Use SCSS for stylesheets')
-        else
-          gems << GemfileEntry.version('sass-rails',
-                                     '~> 4.0.3',
-                                     'Use SCSS for stylesheets')
-        end
-
-        gems << GemfileEntry.version('uglifier',
-                                   '>= 1.3.0',
-                                   'Use Uglifier as compressor for JavaScript assets')
-
-        gems
+        [
+          GemfileEntry.version('sass-rails',
+                               '~> 4.0.3',
+                               'Use SCSS for stylesheets'),
+          GemfileEntry.version('uglifier',
+                               '>= 1.3.0',
+                               'Use Uglifier as compressor for JavaScript assets')
+        ]
       end
 
       def jbuilder_gemfile_entry
@@ -294,7 +285,7 @@
       end
 
       def javascript_runtime_gemfile_entry
-        comment = 'See https://github.com/sstephenson/execjs#readme for more supported runtimes'
+        comment = 'See https://github.com/rails/execjs#readme for more supported runtimes'
         if defined?(JRUBY_VERSION)
           GemfileEntry.version 'therubyrhino', nil, comment
         else
diff -Nru rails-4.1.8/railties/lib/rails/generators/rails/app/app_generator.rb rails-4.1.10/railties/lib/rails/generators/rails/app/app_generator.rb
--- rails-4.1.8/railties/lib/rails/generators/rails/app/app_generator.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/rails/app/app_generator.rb	2015-03-19 13:48:26.000000000 -0300
@@ -334,7 +334,7 @@
     #
     # This class should be called before the AppGenerator is required and started
     # since it configures and mutates ARGV correctly.
-    class ARGVScrubber # :nodoc
+    class ARGVScrubber # :nodoc:
       def initialize(argv = ARGV)
         @argv = argv
       end
diff -Nru rails-4.1.8/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt rails-4.1.10/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt
--- rails-4.1.8/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt	2015-03-19 13:48:26.000000000 -0300
@@ -7,7 +7,7 @@
 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
 // compiled file.
 //
-// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
+// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
 // about supported directives.
 //
 <% unless options[:skip_javascript] -%>
diff -Nru rails-4.1.8/railties/lib/rails/generators/rails/app/templates/config/application.rb rails-4.1.10/railties/lib/rails/generators/rails/app/templates/config/application.rb
--- rails-4.1.8/railties/lib/rails/generators/rails/app/templates/config/application.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/rails/app/templates/config/application.rb	2015-03-19 13:48:26.000000000 -0300
@@ -3,6 +3,7 @@
 <% if include_all_railties? -%>
 require 'rails/all'
 <% else -%>
+require "rails"
 # Pick the frameworks you want:
 require "active_model/railtie"
 <%= comment_if :skip_active_record %>require "active_record/railtie"
diff -Nru rails-4.1.8/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js rails-4.1.10/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js
--- rails-4.1.8/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js	2015-03-19 13:48:26.000000000 -0300
@@ -7,7 +7,7 @@
 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
 // compiled file.
 //
-// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
+// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
 // about supported directives.
 //
 //= require_tree .
diff -Nru rails-4.1.8/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb rails-4.1.10/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb
--- rails-4.1.8/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb	2015-03-19 13:48:26.000000000 -0300
@@ -10,7 +10,9 @@
 <% end -%>
 require "rails/test_help"
 
-Rails.backtrace_cleaner.remove_silencers!
+# Filter out Minitest backtrace while allowing backtrace from other libraries
+# to be shown.
+Minitest.backtrace_filter = Minitest::BacktraceFilter.new
 
 # Load support files
 Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
diff -Nru rails-4.1.8/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb rails-4.1.10/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb
--- rails-4.1.8/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb	2015-03-19 13:48:26.000000000 -0300
@@ -29,8 +29,10 @@
           write("end", route_length - index)
         end
 
-        # route prepends two spaces onto the front of the string that is passed, this corrects that
-        route route_string[2..-1]
+        # route prepends two spaces onto the front of the string that is passed, this corrects that.
+        # Also it adds a \n to the end of each line, as route already adds that
+        # we need to correct that too.
+        route route_string[2..-2]
       end
 
       private
diff -Nru rails-4.1.8/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb rails-4.1.10/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
--- rails-4.1.8/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb	2015-03-19 13:48:26.000000000 -0300
@@ -7,6 +7,7 @@
 
       check_class_collision suffix: "Controller"
 
+      class_option :helper, type: :boolean
       class_option :orm, banner: "NAME", type: :string, required: true,
                          desc: "ORM to generate the controller for"
 
diff -Nru rails-4.1.8/railties/test/application/configuration_test.rb rails-4.1.10/railties/test/application/configuration_test.rb
--- rails-4.1.8/railties/test/application/configuration_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/test/application/configuration_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -255,9 +255,9 @@
     end
 
     test "Use key_generator when secret_key_base is set" do
-      make_basic_app do |app|
-        app.secrets.secret_key_base = 'b3c631c314c0bbca50c1b2843150fe33'
-        app.config.session_store :disabled
+      make_basic_app do |application|
+        application.secrets.secret_key_base = 'b3c631c314c0bbca50c1b2843150fe33'
+        application.config.session_store :disabled
       end
 
       class ::OmgController < ActionController::Base
@@ -275,9 +275,9 @@
     end
 
     test "application verifier can be used in the entire application" do
-      make_basic_app do |app|
-        app.secrets.secret_key_base = 'b3c631c314c0bbca50c1b2843150fe33'
-        app.config.session_store :disabled
+      make_basic_app do |application|
+        application.secrets.secret_key_base = 'b3c631c314c0bbca50c1b2843150fe33'
+        application.config.session_store :disabled
       end
 
       message = app.message_verifier(:sensitive_value).generate("some_value")
@@ -289,10 +289,55 @@
       assert_equal 'some_value', verifier.verify(message)
     end
 
+    test "application message verifier can be used when the key_generator is ActiveSupport::LegacyKeyGenerator" do
+      app_file 'config/initializers/secret_token.rb', <<-RUBY
+        Rails.application.config.secret_token = "b3c631c314c0bbca50c1b2843150fe33"
+      RUBY
+      app_file 'config/secrets.yml', <<-YAML
+        development:
+          secret_key_base:
+      YAML
+      require "#{app_path}/config/environment"
+
+
+      assert_equal app.env_config['action_dispatch.key_generator'], Rails.application.key_generator
+      assert_equal app.env_config['action_dispatch.key_generator'].class, ActiveSupport::LegacyKeyGenerator
+      message = app.message_verifier(:sensitive_value).generate("some_value")
+      assert_equal 'some_value', Rails.application.message_verifier(:sensitive_value).verify(message)
+    end
+
+    test "warns when secrets.secret_key_base is blank and config.secret_token is set" do
+      app_file 'config/initializers/secret_token.rb', <<-RUBY
+        Rails.application.config.secret_token = "b3c631c314c0bbca50c1b2843150fe33"
+      RUBY
+      app_file 'config/secrets.yml', <<-YAML
+        development:
+          secret_key_base:
+      YAML
+      require "#{app_path}/config/environment"
+
+      assert_deprecated(/You didn't set `secret_key_base`./) do
+        app.env_config
+      end
+    end
+
+    test "prefer secrets.secret_token over config.secret_token" do
+      app_file 'config/initializers/secret_token.rb', <<-RUBY
+        Rails.application.config.secret_token = ""
+      RUBY
+      app_file 'config/secrets.yml', <<-YAML
+        development:
+          secret_token: 3b7cd727ee24e8444053437c36cc66c3
+      YAML
+      require "#{app_path}/config/environment"
+
+      assert_equal '3b7cd727ee24e8444053437c36cc66c3', app.secrets.secret_token
+    end
+
     test "application verifier can build different verifiers" do
-      make_basic_app do |app|
-        app.secrets.secret_key_base = 'b3c631c314c0bbca50c1b2843150fe33'
-        app.config.session_store :disabled
+      make_basic_app do |application|
+        application.secrets.secret_key_base = 'b3c631c314c0bbca50c1b2843150fe33'
+        application.config.session_store :disabled
       end
 
       default_verifier = app.message_verifier(:sensitive_value)
@@ -329,6 +374,21 @@
       assert_equal '3b7cd727ee24e8444053437c36cc66c3', app.secrets.secret_key_base
     end
 
+    test "config.secret_token over-writes a blank secrets.secret_token" do
+      app_file 'config/initializers/secret_token.rb', <<-RUBY
+        Rails.application.config.secret_token = "b3c631c314c0bbca50c1b2843150fe33"
+      RUBY
+      app_file 'config/secrets.yml', <<-YAML
+        development:
+          secret_key_base:
+          secret_token:
+      YAML
+      require "#{app_path}/config/environment"
+
+      assert_equal 'b3c631c314c0bbca50c1b2843150fe33', app.secrets.secret_token
+      assert_equal 'b3c631c314c0bbca50c1b2843150fe33', app.config.secret_token
+    end
+
     test "custom secrets saved in config/secrets.yml are loaded in app secrets" do
       app_file 'config/secrets.yml', <<-YAML
         development:
@@ -350,6 +410,51 @@
       assert_nil app.secrets.not_defined
     end
 
+    test "config.secret_key_base over-writes a blank secrets.secret_key_base" do
+      app_file 'config/initializers/secret_token.rb', <<-RUBY
+        Rails.application.config.secret_key_base = "iaminallyoursecretkeybase"
+      RUBY
+      app_file 'config/secrets.yml', <<-YAML
+        development:
+          secret_key_base:
+      YAML
+      require "#{app_path}/config/environment"
+
+      assert_equal "iaminallyoursecretkeybase", app.secrets.secret_key_base
+    end
+
+    test "uses ActiveSupport::LegacyKeyGenerator as app.key_generator when secrets.secret_key_base is blank" do
+      app_file 'config/initializers/secret_token.rb', <<-RUBY
+        Rails.application.config.secret_token = "b3c631c314c0bbca50c1b2843150fe33"
+      RUBY
+      app_file 'config/secrets.yml', <<-YAML
+        development:
+          secret_key_base:
+      YAML
+      require "#{app_path}/config/environment"
+
+      assert_equal 'b3c631c314c0bbca50c1b2843150fe33', app.config.secret_token
+      assert_equal nil, app.secrets.secret_key_base
+      assert_equal app.key_generator.class, ActiveSupport::LegacyKeyGenerator
+    end
+
+    test "uses ActiveSupport::LegacyKeyGenerator with config.secret_token as app.key_generator when secrets.secret_key_base is blank" do
+      app_file 'config/initializers/secret_token.rb', <<-RUBY
+        Rails.application.config.secret_token = ""
+      RUBY
+      app_file 'config/secrets.yml', <<-YAML
+        development:
+          secret_key_base:
+      YAML
+      require "#{app_path}/config/environment"
+
+      assert_equal '', app.config.secret_token
+      assert_equal nil, app.secrets.secret_key_base
+      assert_raise ArgumentError, /\AA secret is required/ do
+        app.key_generator
+      end
+    end
+
     test "protect from forgery is the default in a new app" do
       make_basic_app
 
@@ -363,6 +468,45 @@
       assert last_response.body =~ /csrf\-param/
     end
 
+    test "default form builder specified as a string" do
+
+      app_file 'config/initializers/form_builder.rb', <<-RUBY
+      class CustomFormBuilder < ActionView::Helpers::FormBuilder
+        def text_field(attribute, *args)
+          label(attribute) + super(attribute, *args)
+        end
+      end
+      Rails.configuration.action_view.default_form_builder = "CustomFormBuilder"
+      RUBY
+
+      app_file 'app/models/post.rb', <<-RUBY
+      class Post
+        include ActiveModel::Model
+        attr_accessor :name
+      end
+      RUBY
+
+
+      app_file 'app/controllers/posts_controller.rb', <<-RUBY
+      class PostsController < ApplicationController
+        def index
+          render inline: "<%= begin; form_for(Post.new) {|f| f.text_field(:name)}; rescue => e; e.to_s; end %>"
+        end
+      end
+      RUBY
+
+      add_to_config <<-RUBY
+        routes.prepend do
+          resources :posts
+        end
+      RUBY
+
+      require "#{app_path}/config/environment"
+
+      get "/posts"
+      assert_match(/label/, last_response.body)
+    end
+
     test "default method for update can be changed" do
       app_file 'app/models/post.rb', <<-RUBY
       class Post
@@ -413,8 +557,8 @@
     end
 
     test "request forgery token param can be changed" do
-      make_basic_app do
-        app.config.action_controller.request_forgery_protection_token = '_xsrf_token_here'
+      make_basic_app do |application|
+        application.config.action_controller.request_forgery_protection_token = '_xsrf_token_here'
       end
 
       class ::OmgController < ActionController::Base
@@ -433,8 +577,8 @@
     end
 
     test "sets ActionDispatch::Response.default_charset" do
-      make_basic_app do |app|
-        app.config.action_dispatch.default_charset = "utf-16"
+      make_basic_app do |application|
+        application.config.action_dispatch.default_charset = "utf-16"
       end
 
       assert_equal "utf-16", ActionDispatch::Response.default_charset
@@ -615,8 +759,8 @@
     end
 
     test "config.action_dispatch.show_exceptions is sent in env" do
-      make_basic_app do |app|
-        app.config.action_dispatch.show_exceptions = true
+      make_basic_app do |application|
+        application.config.action_dispatch.show_exceptions = true
       end
 
       class ::OmgController < ActionController::Base
@@ -739,8 +883,8 @@
     end
 
     test "config.action_dispatch.ignore_accept_header" do
-      make_basic_app do |app|
-        app.config.action_dispatch.ignore_accept_header = true
+      make_basic_app do |application|
+        application.config.action_dispatch.ignore_accept_header = true
       end
 
       class ::OmgController < ActionController::Base
@@ -777,9 +921,9 @@
 
     test "config.session_store with :active_record_store with activerecord-session_store gem" do
       begin
-        make_basic_app do |app|
+        make_basic_app do |application|
           ActionDispatch::Session::ActiveRecordStore = Class.new(ActionDispatch::Session::CookieStore)
-          app.config.session_store :active_record_store
+          application.config.session_store :active_record_store
         end
       ensure
         ActionDispatch::Session.send :remove_const, :ActiveRecordStore
@@ -788,16 +932,16 @@
 
     test "config.session_store with :active_record_store without activerecord-session_store gem" do
       assert_raise RuntimeError, /activerecord-session_store/ do
-        make_basic_app do |app|
-          app.config.session_store :active_record_store
+        make_basic_app do |application|
+          application.config.session_store :active_record_store
         end
       end
     end
 
     test "config.log_level with custom logger" do
-      make_basic_app do |app|
-        app.config.logger = Logger.new(STDOUT)
-        app.config.log_level = :info
+      make_basic_app do |application|
+        application.config.logger = Logger.new(STDOUT)
+        application.config.log_level = :info
       end
       assert_equal Logger::INFO, Rails.logger.level
     end
diff -Nru rails-4.1.8/railties/test/application/initializers/i18n_test.rb rails-4.1.10/railties/test/application/initializers/i18n_test.rb
--- rails-4.1.8/railties/test/application/initializers/i18n_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/test/application/initializers/i18n_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -198,7 +198,9 @@
       end
     end
 
-    test "disable config.i18n.enforce_available_locales" do
+    test "disable config.i18n.enforce_available_locales when initial value is nil" do
+      I18n.enforce_available_locales = nil
+
       add_to_config <<-RUBY
         config.i18n.enforce_available_locales = false
         config.i18n.default_locale = :fr
@@ -213,10 +215,28 @@
       end
     end
 
-    test "default config.i18n.enforce_available_locales does not override I18n.enforce_available_locales" do
+    test "disable config.i18n.enforce_available_locales when initial value is true" do
+      I18n.enforce_available_locales = true
+
+      add_to_config <<-RUBY
+        config.i18n.enforce_available_locales = false
+        config.i18n.default_locale = :fr
+      RUBY
+
+      output = capture(:stderr) { load_app }
+      assert_no_match %r{deprecated.*enforce_available_locales}, output
+      assert_equal false, I18n.enforce_available_locales
+
+      assert_nothing_raised do
+        I18n.locale = :es
+      end
+    end
+
+    test "disable config.i18n.enforce_available_locales when initial value is false" do
       I18n.enforce_available_locales = false
 
       add_to_config <<-RUBY
+        config.i18n.enforce_available_locales = false
         config.i18n.default_locale = :fr
       RUBY
 
diff -Nru rails-4.1.8/railties/test/application/middleware/session_test.rb rails-4.1.10/railties/test/application/middleware/session_test.rb
--- rails-4.1.8/railties/test/application/middleware/session_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/test/application/middleware/session_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -203,7 +203,7 @@
       RUBY
 
       add_to_config <<-RUBY
-        config.secret_token = "3b7cd727ee24e8444053437c36cc66c4"
+        secrets.secret_token = "3b7cd727ee24e8444053437c36cc66c4"
       RUBY
 
       require "#{app_path}/config/environment"
@@ -258,7 +258,7 @@
       RUBY
 
       add_to_config <<-RUBY
-        config.secret_token = "3b7cd727ee24e8444053437c36cc66c4"
+        secrets.secret_token = "3b7cd727ee24e8444053437c36cc66c4"
       RUBY
 
       require "#{app_path}/config/environment"
@@ -317,7 +317,7 @@
       RUBY
 
       add_to_config <<-RUBY
-        config.secret_token = "3b7cd727ee24e8444053437c36cc66c4"
+        secrets.secret_token = "3b7cd727ee24e8444053437c36cc66c4"
         secrets.secret_key_base = nil
       RUBY
 
@@ -334,7 +334,7 @@
       get '/foo/read_signed_cookie'
       assert_equal '2', last_response.body
 
-      verifier = ActiveSupport::MessageVerifier.new(app.config.secret_token)
+      verifier = ActiveSupport::MessageVerifier.new(app.secrets.secret_token)
 
       get '/foo/read_raw_cookie'
       assert_equal 2, verifier.verify(last_response.body)['foo']
diff -Nru rails-4.1.8/railties/test/application/multiple_applications_test.rb rails-4.1.10/railties/test/application/multiple_applications_test.rb
--- rails-4.1.8/railties/test/application/multiple_applications_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/test/application/multiple_applications_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -8,6 +8,7 @@
       build_app(initializers: true)
       boot_rails
       require "#{rails_root}/config/environment"
+      Rails.application.config.some_setting = 'something_or_other'
     end
 
     def teardown
@@ -18,7 +19,7 @@
       clone = Rails.application.clone
 
       assert_equal Rails.application.config, clone.config, "The cloned application should get a copy of the config"
-      assert_equal Rails.application.config.secret_key_base, clone.config.secret_key_base, "The base secret key on the config should be the same"
+      assert_equal Rails.application.config.some_setting, clone.config.some_setting, "The some_setting on the config should be the same"
     end
 
     def test_inheriting_multiple_times_from_application
@@ -160,13 +161,14 @@
 
     def test_inserting_configuration_into_application
       app = AppTemplate::Application.new(config: Rails.application.config)
-      new_config = Rails::Application::Configuration.new("root_of_application")
-      new_config.secret_key_base = "some_secret_key_dude"
-      app.config.secret_key_base = "a_different_secret_key"
+      app.config.some_setting = "a_different_setting"
+      assert_equal "a_different_setting", app.config.some_setting, "The configuration's some_setting should be set."
 
-      assert_equal "a_different_secret_key", app.config.secret_key_base, "The configuration's secret key should be set."
+      new_config = Rails::Application::Configuration.new("root_of_application")
+      new_config.some_setting = "some_setting_dude"
       app.config = new_config
-      assert_equal "some_secret_key_dude", app.config.secret_key_base, "The configuration's secret key should have changed."
+
+      assert_equal "some_setting_dude", app.config.some_setting, "The configuration's some_setting should have changed."
       assert_equal "root_of_application", app.config.root, "The root should have changed to the new config's root."
       assert_equal new_config, app.config, "The application's config should have changed to the new config."
     end
diff -Nru rails-4.1.8/railties/test/application/rake/dbs_test.rb rails-4.1.10/railties/test/application/rake/dbs_test.rb
--- rails-4.1.8/railties/test/application/rake/dbs_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/test/application/rake/dbs_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -161,6 +161,31 @@
         end
       end
 
+      test 'db:schema:load and db:structure:load do not purge the existing database' do
+        Dir.chdir(app_path) do
+          `bin/rails runner 'ActiveRecord::Base.connection.create_table(:posts) {|t| t.string :title }'`
+
+          app_file 'db/schema.rb', <<-RUBY
+            ActiveRecord::Schema.define(version: 20140423102712) do
+              create_table(:comments) {}
+            end
+          RUBY
+
+          list_tables = lambda { `bin/rails runner 'p ActiveRecord::Base.connection.tables'`.strip }
+
+          assert_equal '["posts"]', list_tables[]
+          `bin/rake db:schema:load`
+          assert_equal '["posts", "comments", "schema_migrations"]', list_tables[]
+
+          app_file 'db/structure.sql', <<-SQL
+            CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255));
+          SQL
+
+          `bin/rake db:structure:load`
+          assert_equal '["posts", "comments", "schema_migrations", "users"]', list_tables[]
+        end
+      end
+
       def db_test_load_structure
         Dir.chdir(app_path) do
           `rails generate model book title:string;
@@ -180,15 +205,6 @@
         db_test_load_structure
       end
 
-      test 'db:test deprecation' do
-        require "#{app_path}/config/environment"
-        Dir.chdir(app_path) do
-          output = `bundle exec rake db:migrate db:test:prepare 2>&1`
-          assert_equal "WARNING: db:test:prepare is deprecated. The Rails test helper now maintains " \
-                       "your test schema automatically, see the release notes for details.\n", output
-        end
-      end
-
       test 'db:setup loads schema and seeds database' do
         begin
           @old_rails_env = ENV["RAILS_ENV"]
diff -Nru rails-4.1.8/railties/test/application/test_test.rb rails-4.1.10/railties/test/application/test_test.rb
--- rails-4.1.8/railties/test/application/test_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/test/application/test_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -193,6 +193,98 @@
       assert_successful_test_run('models/user_test.rb')
     end
 
+    # TODO: would be nice if we could detect the schema change automatically.
+    # For now, the user has to synchronize the schema manually.
+    # This test-case serves as a reminder for this use-case.
+    test "manually synchronize test schema after rollback" do
+      output  = script('generate model user name:string')
+      version = output.match(/(\d+)_create_users\.rb/)[1]
+
+      app_file 'test/models/user_test.rb', <<-RUBY
+        require 'test_helper'
+
+        class UserTest < ActiveSupport::TestCase
+          test "user" do
+            assert_equal ["id", "name"], User.columns_hash.keys
+          end
+        end
+      RUBY
+      app_file 'db/schema.rb', <<-RUBY
+        ActiveRecord::Schema.define(version: #{version}) do
+          create_table :users do |t|
+            t.string :name
+          end
+        end
+      RUBY
+
+      assert_successful_test_run "models/user_test.rb"
+
+      # Simulate `db:rollback` + edit of the migration file + `db:migrate`
+      app_file 'db/schema.rb', <<-RUBY
+        ActiveRecord::Schema.define(version: #{version}) do
+          create_table :users do |t|
+            t.string :name
+            t.integer :age
+          end
+        end
+      RUBY
+
+      assert_successful_test_run "models/user_test.rb"
+
+      Dir.chdir(app_path) { `bin/rake db:test:prepare` }
+
+      assert_unsuccessful_run "models/user_test.rb", <<-ASSERTION
+Expected: ["id", "name"]
+  Actual: ["id", "name", "age"]
+      ASSERTION
+    end
+
+    test "hooks for plugins" do
+      output  = script('generate model user name:string')
+      version = output.match(/(\d+)_create_users\.rb/)[1]
+
+      app_file 'lib/tasks/hooks.rake', <<-RUBY
+        task :before_hook do
+          has_user_table = ActiveRecord::Base.connection.table_exists?('users')
+          puts "before: " + has_user_table.to_s
+        end
+
+        task :after_hook do
+          has_user_table = ActiveRecord::Base.connection.table_exists?('users')
+          puts "after: " + has_user_table.to_s
+        end
+
+        Rake::Task["db:test:prepare"].enhance [:before_hook] do
+          Rake::Task[:after_hook].invoke
+        end
+      RUBY
+      app_file 'test/models/user_test.rb', <<-RUBY
+        require 'test_helper'
+        class UserTest < ActiveSupport::TestCase
+          test "user" do
+            User.create! name: "Jon"
+          end
+        end
+      RUBY
+
+      # Simulate `db:migrate`
+      app_file 'db/schema.rb', <<-RUBY
+        ActiveRecord::Schema.define(version: #{version}) do
+          create_table :users do |t|
+            t.string :name
+          end
+        end
+      RUBY
+
+      output = assert_successful_test_run "models/user_test.rb"
+      assert_includes output, "before: false\nafter: true"
+
+      # running tests again won't trigger a schema update
+      output = assert_successful_test_run "models/user_test.rb"
+      assert_not_includes output, "before:"
+      assert_not_includes output, "after:"
+    end
+
     private
       def assert_unsuccessful_run(name, message)
         result = run_test_file(name)
@@ -208,7 +300,7 @@
       end
 
       def run_test_file(name, options = {})
-        ruby '-Itest', "#{app_path}/test/#{name}", options
+        ruby '-Itest', "#{app_path}/test/#{name}", options.deep_merge(env: {"RAILS_ENV" => "test"})
       end
 
       def ruby(*args)
diff -Nru rails-4.1.8/railties/test/application/url_generation_test.rb rails-4.1.10/railties/test/application/url_generation_test.rb
--- rails-4.1.8/railties/test/application/url_generation_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/test/application/url_generation_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -15,7 +15,7 @@
       require "action_view/railtie"
 
       class MyApp < Rails::Application
-        config.secret_key_base = "3b7cd727ee24e8444053437c36cc66c4"
+        secrets.secret_key_base = "3b7cd727ee24e8444053437c36cc66c4"
         config.session_store :cookie_store, key: "_myapp_session"
         config.active_support.deprecation = :log
         config.eager_load = false
diff -Nru rails-4.1.8/railties/test/generators/actions_test.rb rails-4.1.10/railties/test/generators/actions_test.rb
--- rails-4.1.8/railties/test/generators/actions_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/test/generators/actions_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -110,7 +110,7 @@
     run_generator
 
     action :environment do
-      '# This wont be added'
+      _ = '# This wont be added'# assignment to silence parse-time warning "unused literal ignored"
       '# This will be added'
     end
 
@@ -200,6 +200,30 @@
     assert_file 'config/routes.rb', /#{Regexp.escape(route_command)}/
   end
 
+  def test_route_should_add_data_with_an_new_line
+    run_generator
+    action :route, "root 'welcome#index'"
+    route_path = File.expand_path("config/routes.rb", destination_root)
+    content = File.read(route_path)
+
+    # Remove all of the comments and blank lines from the routes file
+    content.gsub!(/^  \#.*\n/, '')
+    content.gsub!(/^\n/, '')
+
+    File.open(route_path, "wb") { |file| file.write(content) }
+    assert_file "config/routes.rb", /\.routes\.draw do\n  root 'welcome#index'\nend\n\z/
+
+    action :route, "resources :product_lines"
+
+    routes = <<-F
+Rails.application.routes.draw do
+  resources :product_lines
+  root 'welcome#index'
+end
+F
+    assert_file "config/routes.rb", routes
+  end
+
   def test_readme
     run_generator
     Rails::Generators::AppGenerator.expects(:source_root).times(2).returns(destination_root)
diff -Nru rails-4.1.8/railties/test/generators/plugin_generator_test.rb rails-4.1.10/railties/test/generators/plugin_generator_test.rb
--- rails-4.1.8/railties/test/generators/plugin_generator_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/test/generators/plugin_generator_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -56,6 +56,7 @@
     assert_file "test/test_helper.rb" do |content|
       assert_match(/require.+test\/dummy\/config\/environment/, content)
       assert_match(/ActiveRecord::Migrator\.migrations_paths.+test\/dummy\/db\/migrate/, content)
+      assert_match(/Minitest\.backtrace_filter = Minitest::BacktraceFilter\.new/, content)
     end
     assert_file "test/bukkits_test.rb", /assert_kind_of Module, Bukkits/
   end
diff -Nru rails-4.1.8/railties/test/generators/scaffold_generator_test.rb rails-4.1.10/railties/test/generators/scaffold_generator_test.rb
--- rails-4.1.8/railties/test/generators/scaffold_generator_test.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/railties/test/generators/scaffold_generator_test.rb	2015-03-19 13:48:26.000000000 -0300
@@ -239,6 +239,29 @@
     assert_file "config/routes.rb", /\.routes\.draw do\s*\|map\|\s*$/
   end
 
+  def test_scaffold_generator_on_revoke_does_not_mutilate_routes
+    run_generator
+
+    route_path = File.expand_path("config/routes.rb", destination_root)
+    content = File.read(route_path)
+
+    # Remove all of the comments and blank lines from the routes file
+    content.gsub!(/^  \#.*\n/, '')
+    content.gsub!(/^\n/, '')
+
+    File.open(route_path, "wb") { |file| file.write(content) }
+    assert_file "config/routes.rb", /\.routes\.draw do\n  resources :product_lines\nend\n\z/
+
+    run_generator ["product_line"], :behavior => :revoke
+
+    assert_file "config/routes.rb", /\.routes\.draw do\nend\n\z/
+  end
+
+  def test_scaffold_generator_ignores_commented_routes
+    run_generator ["product"]
+    assert_file "config/routes.rb", /\.routes\.draw do\n  resources :products\n/
+  end
+
   def test_scaffold_generator_no_assets_with_switch_no_assets
     run_generator [ "posts", "--no-assets" ]
     assert_no_file "app/assets/stylesheets/scaffold.css"
@@ -260,6 +283,20 @@
     end
   end
 
+  def test_scaffold_generator_no_helper_with_switch_no_helper
+    output = run_generator [ "posts", "--no-helper" ]
+
+    assert_no_match /error/, output
+    assert_no_file "app/helpers/posts_helper.rb"
+  end
+
+  def test_scaffold_generator_no_helper_with_switch_helper_false
+    output = run_generator [ "posts", "--helper=false" ]
+
+    assert_no_match /error/, output
+    assert_no_file "app/helpers/post_helper.rb"
+  end
+
   def test_scaffold_generator_no_stylesheets
     run_generator [ "posts", "--no-stylesheets" ]
     assert_no_file "app/assets/stylesheets/scaffold.css"
diff -Nru rails-4.1.8/tasks/release.rb rails-4.1.10/tasks/release.rb
--- rails-4.1.8/tasks/release.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/tasks/release.rb	2015-03-19 13:48:26.000000000 -0300
@@ -102,7 +102,7 @@
       abort "[ABORTING] `git status` reports a dirty tree. Make sure all changes are committed"
     end
 
-    unless ENV['SKIP_TAG'] || `git tag | grep '^#{tag}$`.strip.empty?
+    unless ENV['SKIP_TAG'] || `git tag | grep '^#{tag}$'`.strip.empty?
       abort "[ABORTING] `git tag` shows that #{tag} already exists. Has this version already\n"\
             "           been released? Git tagging can be skipped by setting SKIP_TAG=1"
     end
diff -Nru rails-4.1.8/.travis.yml rails-4.1.10/.travis.yml
--- rails-4.1.8/.travis.yml	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/.travis.yml	2015-03-19 13:48:26.000000000 -0300
@@ -1,11 +1,17 @@
+language: ruby
+sudo: false
 script: 'ci/travis.rb'
 before_install:
-  - travis_retry gem install bundler
   - "rvm current | grep 'jruby' && export AR_JDBC=true || echo"
+  - "rm ${BUNDLE_GEMFILE}.lock"
+before_script:
+  - bundle update
+cache: bundler
 rvm:
   - 1.9.3
   - 2.0.0
   - 2.1
+  - 2.2
   - ruby-head
   - rbx-2
   - jruby
@@ -34,6 +40,6 @@
     on_failure: always
     rooms:
       - secure: "YA1alef1ESHWGFNVwvmVGCkMe4cUy4j+UcNvMUESraceiAfVyRMAovlQBGs6\n9kBRm7DHYBUXYC2ABQoJbQRLDr/1B5JPf/M8+Qd7BKu8tcDC03U01SMHFLpO\naOs/HLXcDxtnnpL07tGVsm0zhMc5N8tq4/L3SHxK7Vi+TacwQzI="
-bundler_args: --path vendor/bundle --without test
+bundler_args: --without test --jobs 3 --retry 3
 services:
   - memcached
diff -Nru rails-4.1.8/version.rb rails-4.1.10/version.rb
--- rails-4.1.8/version.rb	2014-11-16 17:42:07.000000000 -0200
+++ rails-4.1.10/version.rb	2015-03-19 13:48:26.000000000 -0300
@@ -7,7 +7,7 @@
   module VERSION
     MAJOR = 4
     MINOR = 1
-    TINY  = 8
+    TINY  = 10
     PRE   = nil
 
     STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")

Attachment: signature.asc
Description: Digital signature


Reply to: