aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml11
-rw-r--r--Gemfile4
-rw-r--r--RAILS_VERSION2
-rw-r--r--actionmailer/CHANGELOG.md64
-rw-r--r--actionmailer/actionmailer.gemspec2
-rw-r--r--actionmailer/lib/action_mailer/base.rb4
-rw-r--r--actionmailer/lib/action_mailer/gem_version.rb6
-rw-r--r--actionpack/CHANGELOG.md411
-rw-r--r--actionpack/actionpack.gemspec2
-rw-r--r--actionpack/lib/abstract_controller/base.rb2
-rw-r--r--actionpack/lib/action_controller/metal/testing.rb2
-rw-r--r--actionpack/lib/action_dispatch/http/mime_type.rb2
-rw-r--r--actionpack/lib/action_dispatch/journey/nfa/transition_table.rb2
-rw-r--r--actionpack/lib/action_dispatch/journey/path/pattern.rb4
-rw-r--r--actionpack/lib/action_dispatch/journey/route.rb6
-rw-r--r--actionpack/lib/action_dispatch/journey/router.rb4
-rw-r--r--actionpack/lib/action_dispatch/routing/inspector.rb4
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb4
-rw-r--r--actionpack/lib/action_dispatch/testing/test_request.rb2
-rw-r--r--actionpack/lib/action_pack/gem_version.rb6
-rw-r--r--actionpack/test/abstract_unit.rb2
-rw-r--r--actionpack/test/controller/filters_test.rb2
-rw-r--r--actionpack/test/controller/routing_test.rb8
-rw-r--r--actionpack/test/dispatch/mime_type_test.rb4
-rw-r--r--actionview/CHANGELOG.md219
-rw-r--r--actionview/actionview.gemspec2
-rw-r--r--actionview/lib/action_view/base.rb4
-rw-r--r--actionview/lib/action_view/gem_version.rb6
-rw-r--r--actionview/lib/action_view/helpers/date_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/form_options_helper.rb4
-rw-r--r--actionview/lib/action_view/helpers/tag_helper.rb2
-rw-r--r--actionview/lib/action_view/layouts.rb2
-rw-r--r--actionview/lib/action_view/template/error.rb2
-rw-r--r--actionview/lib/action_view/template/handlers.rb2
-rw-r--r--actionview/lib/action_view/template/resolver.rb2
-rw-r--r--actionview/lib/action_view/template/types.rb2
-rw-r--r--actionview/test/abstract_unit.rb2
-rw-r--r--actionview/test/actionpack/controller/view_paths_test.rb2
-rw-r--r--actionview/test/template/erb_util_test.rb2
-rw-r--r--actionview/test/template/render_test.rb2
-rw-r--r--activejob/CHANGELOG.md2
-rw-r--r--activejob/activejob.gemspec2
-rw-r--r--activejob/lib/active_job/gem_version.rb6
-rw-r--r--activejob/test/support/delayed_job/delayed/backend/test.rb4
-rw-r--r--activejob/test/support/integration/adapters/sidekiq.rb2
-rw-r--r--activemodel/CHANGELOG.md62
-rw-r--r--activemodel/activemodel.gemspec2
-rw-r--r--activemodel/lib/active_model/gem_version.rb6
-rw-r--r--activemodel/test/cases/validations/numericality_validation_test.rb4
-rw-r--r--activemodel/test/cases/validations_test.rb2
-rw-r--r--activerecord/CHANGELOG.md1337
-rw-r--r--activerecord/activerecord.gemspec2
-rw-r--r--activerecord/examples/performance.rb4
-rw-r--r--activerecord/lib/active_record/associations.rb2
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb10
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb4
-rw-r--r--activerecord/lib/active_record/associations/join_dependency.rb2
-rw-r--r--activerecord/lib/active_record/associations/preloader/has_many_through.rb2
-rw-r--r--activerecord/lib/active_record/attribute_assignment.rb2
-rw-r--r--activerecord/lib/active_record/autosave_association.rb6
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb2
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql_adapter.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb16
-rw-r--r--activerecord/lib/active_record/connection_adapters/schema_cache.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb10
-rw-r--r--activerecord/lib/active_record/fixtures.rb6
-rw-r--r--activerecord/lib/active_record/gem_version.rb6
-rw-r--r--activerecord/lib/active_record/inheritance.rb2
-rw-r--r--activerecord/lib/active_record/migration.rb2
-rw-r--r--activerecord/lib/active_record/model_schema.rb2
-rw-r--r--activerecord/lib/active_record/railties/databases.rake2
-rw-r--r--activerecord/lib/active_record/readonly_attributes.rb2
-rw-r--r--activerecord/lib/active_record/reflection.rb2
-rw-r--r--activerecord/lib/active_record/relation.rb8
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb2
-rw-r--r--activerecord/lib/active_record/serialization.rb2
-rw-r--r--activerecord/lib/active_record/statement_cache.rb2
-rw-r--r--activerecord/lib/active_record/validations/presence.rb2
-rw-r--r--activerecord/test/cases/adapters/mysql/connection_test.rb4
-rw-r--r--activerecord/test/cases/adapters/mysql/reserved_word_test.rb4
-rw-r--r--activerecord/test/cases/adapters/mysql/schema_test.rb2
-rw-r--r--activerecord/test/cases/adapters/mysql2/connection_test.rb4
-rw-r--r--activerecord/test/cases/adapters/mysql2/reserved_word_test.rb4
-rw-r--r--activerecord/test/cases/adapters/mysql2/schema_test.rb2
-rw-r--r--activerecord/test/cases/adapters/postgresql/connection_test.rb4
-rw-r--r--activerecord/test/cases/adapters/postgresql/schema_test.rb2
-rw-r--r--activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb8
-rw-r--r--activerecord/test/cases/associations/eager_load_nested_include_test.rb4
-rw-r--r--activerecord/test/cases/associations/eager_test.rb20
-rw-r--r--activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb2
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb2
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb2
-rw-r--r--activerecord/test/cases/associations/inner_join_association_test.rb2
-rw-r--r--activerecord/test/cases/associations/join_model_test.rb6
-rw-r--r--activerecord/test/cases/associations_test.rb2
-rw-r--r--activerecord/test/cases/autosave_association_test.rb22
-rw-r--r--activerecord/test/cases/finder_test.rb8
-rw-r--r--activerecord/test/cases/migration/column_positioning_test.rb12
-rw-r--r--activerecord/test/cases/migrator_test.rb4
-rw-r--r--activerecord/test/cases/nested_attributes_test.rb12
-rw-r--r--activerecord/test/cases/persistence_test.rb4
-rw-r--r--activerecord/test/cases/pooled_connections_test.rb2
-rw-r--r--activerecord/test/cases/reflection_test.rb4
-rw-r--r--activerecord/test/cases/relations_test.rb8
-rw-r--r--activerecord/test/cases/scoping/default_scoping_test.rb64
-rw-r--r--activerecord/test/cases/test_case.rb2
-rw-r--r--activerecord/test/cases/transactions_test.rb6
-rw-r--r--activerecord/test/cases/validations_repair_helper.rb8
-rw-r--r--activerecord/test/models/customer.rb2
-rw-r--r--activerecord/test/models/pirate.rb4
-rw-r--r--activerecord/test/models/ship.rb2
-rw-r--r--activesupport/CHANGELOG.md389
-rw-r--r--activesupport/activesupport.gemspec2
-rwxr-xr-xactivesupport/bin/generate_tables2
-rw-r--r--activesupport/lib/active_support/core_ext/array/conversions.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/big_decimal/conversions.rb13
-rw-r--r--activesupport/lib/active_support/core_ext/hash/keys.rb8
-rw-r--r--activesupport/lib/active_support/core_ext/numeric/conversions.rb28
-rw-r--r--activesupport/lib/active_support/core_ext/object/deep_dup.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/object/instance_variables.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/object/to_query.rb2
-rw-r--r--activesupport/lib/active_support/dependencies.rb2
-rw-r--r--activesupport/lib/active_support/gem_version.rb6
-rw-r--r--activesupport/lib/active_support/number_helper/number_to_human_converter.rb2
-rw-r--r--activesupport/lib/active_support/testing/assertions.rb2
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb2
-rw-r--r--activesupport/lib/active_support/xml_mini/jdom.rb2
-rw-r--r--activesupport/test/core_ext/enumerable_test.rb4
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb2
-rw-r--r--activesupport/test/core_ext/object/try_test.rb4
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb8
-rw-r--r--activesupport/test/multibyte_chars_test.rb2
-rw-r--r--activesupport/test/multibyte_conformance_test.rb2
-rw-r--r--activesupport/test/rescuable_test.rb4
-rwxr-xr-xci/travis.rb2
-rw-r--r--guides/CHANGELOG.md28
-rw-r--r--guides/rails_guides/kindle.rb2
-rw-r--r--guides/source/active_support_core_extensions.md2
-rw-r--r--guides/source/i18n.md2
-rw-r--r--rails.gemspec2
-rw-r--r--railties/CHANGELOG.md209
-rw-r--r--railties/lib/rails/application/routes_reloader.rb4
-rw-r--r--railties/lib/rails/commands/plugin.rb2
-rw-r--r--railties/lib/rails/gem_version.rb6
-rw-r--r--railties/lib/rails/generators.rb4
-rw-r--r--railties/lib/rails/generators/actions.rb2
-rw-r--r--railties/lib/rails/generators/app_base.rb3
-rw-r--r--railties/lib/rails/generators/base.rb2
-rw-r--r--railties/lib/rails/generators/named_base.rb4
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb4
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt2
-rw-r--r--railties/lib/rails/generators/resource_helpers.rb4
-rw-r--r--railties/lib/rails/info.rb4
-rw-r--r--railties/lib/rails/paths.rb10
-rw-r--r--railties/lib/rails/ruby_version_check.rb6
-rw-r--r--railties/railties.gemspec2
-rw-r--r--railties/test/railties/engine_test.rb2
-rw-r--r--version.rb6
161 files changed, 345 insertions, 3067 deletions
diff --git a/.travis.yml b/.travis.yml
index 2823a5456f..5352873d8f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,29 +9,26 @@ env:
matrix:
- "GEM=railties"
- "GEM=ap"
- - "GEM=am,amo,as,av,aj"
+ - "GEM=aj"
+ - "GEM=am,amo,as,av"
- "GEM=ar:mysql"
- "GEM=ar:mysql2"
- "GEM=ar:sqlite3"
- "GEM=ar:postgresql"
- "GEM=aj:integration"
rvm:
- - 1.9.3
- - 2.0.0
- 2.1
- ruby-head
- rbx-2
- jruby
matrix:
allow_failures:
- - rvm: 1.9.3
- env: "GEM=ar:mysql"
- - rvm: 2.0.0
- env: "GEM=ar:mysql"
- rvm: ruby-head
env: "GEM=ar:mysql"
- rvm: rbx-2
- rvm: jruby
+ - env: "GEM=aj"
+ - env: "GEM=aj:integration"
fast_finish: true
notifications:
email: false
diff --git a/Gemfile b/Gemfile
index 99e2cb9f58..e2cbce24c8 100644
--- a/Gemfile
+++ b/Gemfile
@@ -11,7 +11,7 @@ gem 'rake', '>= 10.3'
gem 'mocha', '~> 0.14', require: false
gem 'rack-cache', '~> 1.2'
-gem 'jquery-rails', '~> 4.0'
+gem 'jquery-rails', github: 'rails/jquery-rails'
gem 'coffee-rails', '~> 4.1.0'
gem 'turbolinks'
@@ -47,7 +47,7 @@ group :job do
gem 'backburner', require: false
gem 'qu-rails', github: "bkeepers/qu", branch: "master", require: false
gem 'qu-redis', require: false
- gem 'delayed_job_active_record', require: false
+ # gem 'delayed_job_active_record', require: false
gem 'sequel', require: false
end
diff --git a/RAILS_VERSION b/RAILS_VERSION
index b86dc8c0c6..2b915d7d5c 100644
--- a/RAILS_VERSION
+++ b/RAILS_VERSION
@@ -1 +1 @@
-4.2.0.beta4
+5.0.0.alpha
diff --git a/actionmailer/CHANGELOG.md b/actionmailer/CHANGELOG.md
index c8b969c59a..88b0962e8c 100644
--- a/actionmailer/CHANGELOG.md
+++ b/actionmailer/CHANGELOG.md
@@ -1,63 +1 @@
-* `MailerGenerator` now generates layouts by default. The HTML mailer layout
- now includes `<html>` and `<body>` tags which improve the spam rating in
- some spam detection engines. Mailers now inherit from `ApplicationMailer`
- which sets the default layout.
-
- *Andy Jeffries*
-
-* `link_to` and `url_for` now generate URLs by default in templates.
- Passing `only_path: false` is no longer needed.
-
- Fixes #16497 and #16589.
-
- *Xavier Noria*, *Richard Schneeman*
-
-* Attachments can now be added while rendering the mail template.
-
- Fixes #16974.
-
- *Christian Felder*
-
-* Add `#deliver_later` and `#deliver_now` methods and deprecate `#deliver` in
- favor of `#deliver_now`. `#deliver_later` will enqueue a job to render and
- deliver the mail instead of delivering it immediately. The job is enqueued
- using the new Active Job framework in Rails and will use the queue that you
- have configured in Rails.
-
- *DHH*, *Abdelkader Boudih*, *Cristian Bica*
-
-* `ActionMailer::Previews` are now class methods instead of instance methods.
-
- *Cristian Bica*
-
-* Deprecate `*_path` helpers in email views. They generated broken links in
- email views and were not the intention of most developers. The `*_url`
- helper is recommended instead.
-
- *Richard Schneeman*
-
-* Raise an exception when attachments are added after `mail` is called.
- This is a safeguard to prevent invalid emails.
-
- Fixes #16163.
-
- *Yves Senn*
-
-* Add `config.action_mailer.show_previews` configuration option.
-
- This configuration option can be used to enable the mail preview in
- environments other than development (such as staging).
-
- Defaults to `true` in development and `false` elsewhere.
-
- *Leonard Garvey*
-
-* Allow preview interceptors to be registered through
- `config.action_mailer.preview_interceptors`.
-
- See #15739.
-
- *Yves Senn*
-
-Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/actionmailer/CHANGELOG.md)
-for previous changes.
+Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/actionmailer/CHANGELOG.md) for previous changes.
diff --git a/actionmailer/actionmailer.gemspec b/actionmailer/actionmailer.gemspec
index b63f4e5c08..f3bddd8382 100644
--- a/actionmailer/actionmailer.gemspec
+++ b/actionmailer/actionmailer.gemspec
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.summary = 'Email composition, delivery, and receiving framework (part of Rails).'
s.description = 'Email on Rails. Compose, deliver, receive, and test emails using the familiar controller/view pattern. First-class support for multipart email and attachments.'
- s.required_ruby_version = '>= 1.9.3'
+ s.required_ruby_version = '>= 2.1.0'
s.license = 'MIT'
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index 23139bcbe8..a88e884ee8 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -859,7 +859,7 @@ module ActionMailer
when user_content_type.present?
user_content_type
when m.has_attachments?
- if m.attachments.detect { |a| a.inline? }
+ if m.attachments.detect(&:inline?)
["multipart", "related", params]
else
["multipart", "mixed", params]
@@ -914,7 +914,7 @@ module ActionMailer
if templates.empty?
raise ActionView::MissingTemplate.new(paths, name, paths, false, 'mailer')
else
- templates.uniq { |t| t.formats }.each(&block)
+ templates.uniq(&:formats).each(&block)
end
end
diff --git a/actionmailer/lib/action_mailer/gem_version.rb b/actionmailer/lib/action_mailer/gem_version.rb
index e568b8f6f2..ac79788cf0 100644
--- a/actionmailer/lib/action_mailer/gem_version.rb
+++ b/actionmailer/lib/action_mailer/gem_version.rb
@@ -5,10 +5,10 @@ module ActionMailer
end
module VERSION
- MAJOR = 4
- MINOR = 2
+ MAJOR = 5
+ MINOR = 0
TINY = 0
- PRE = "beta4"
+ PRE = "alpha"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 07063c953a..556545c0d8 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,410 +1 @@
-* Restore handling of a bare `Authorization` header, without `token=`
- prefix.
-
- Fixes #17108.
-
- *Guo Xiang Tan*
-
-* Deprecate use of string keys in URL helpers.
-
- Use symbols instead.
- Fixes #16958.
-
- *Byron Bischoff*, *Melanie Gilman*
-
-* Deprecate the `only_path` option on `*_path` helpers.
-
- In cases where this option is set to `true`, the option is redundant and can
- be safely removed; otherwise, the corresponding `*_url` helper should be
- used instead.
-
- Fixes #17294.
-
- *Dan Olson*, *Godfrey Chan*
-
-* Improve Journey compliance to RFC 3986.
-
- The scanner in Journey failed to recognize routes that use literals
- from the sub-delims section of RFC 3986. It's now able to parse those
- authorized delimiters and route as expected.
-
- Fixes #17212.
-
- *Nicolas Cavigneaux*
-
-* Deprecate implicit Array conversion for Response objects. It was added
- (using `#to_ary`) so we could conveniently use implicit splatting:
-
- status, headers, body = response
-
- But it also means `response + response` works and `[response].flatten`
- cascades down to the Rack body. Nonsense behavior. Instead, rely on
- explicit conversion and splatting with `#to_a`:
-
- status, header, body = *response
-
- *Jeremy Kemper*
-
-* Don't rescue `IPAddr::InvalidAddressError`.
-
- `IPAddr::InvalidAddressError` does not exist in Ruby 1.9.3
- and fails for JRuby in 1.9 mode.
-
- *Peter Suschlik*
-
-* Fix bug where the router would ignore any constraints added to redirect
- routes.
-
- Fixes #16605.
-
- *Agis Anastasopoulos*
-
-* Allow `config.action_dispatch.trusted_proxies` to accept an IPAddr object.
-
- Example:
-
- # config/environments/production.rb
- config.action_dispatch.trusted_proxies = IPAddr.new('4.8.15.0/16')
-
- *Sam Aarons*
-
-* Avoid duplicating routes for HEAD requests.
-
- Instead of duplicating the routes, we will first match the HEAD request to
- HEAD routes. If no match is found, we will then map the HEAD request to
- GET routes.
-
- *Guo Xiang Tan*, *Andrew White*
-
-* Requests that hit `ActionDispatch::Static` can now take advantage
- of gzipped assets on disk. By default a gzip asset will be served if
- the client supports gzip and a compressed file is on disk.
-
- *Richard Schneeman*
-
-* `ActionController::Parameters` will stop inheriting from `Hash` and
- `HashWithIndifferentAccess` in the next major release. If you use any method
- that is not available on `ActionController::Parameters` you should consider
- calling `#to_h` to convert it to a `Hash` first before calling that method.
-
- *Prem Sichanugrist*
-
-* `ActionController::Parameters#to_h` now returns a `Hash` with unpermitted
- keys removed. This change is to reflect on a security concern where some
- method performed on an `ActionController::Parameters` may yield a `Hash`
- object which does not maintain `permitted?` status. If you would like to
- get a `Hash` with all the keys intact, duplicate and mark it as permitted
- before calling `#to_h`.
-
- params = ActionController::Parameters.new({
- name: 'Senjougahara Hitagi',
- oddity: 'Heavy stone crab'
- })
- params.to_h
- # => {}
-
- unsafe_params = params.dup.permit!
- unsafe_params.to_h
- # => {"name"=>"Senjougahara Hitagi", "oddity"=>"Heavy stone crab"}
-
- safe_params = params.permit(:name)
- safe_params.to_h
- # => {"name"=>"Senjougahara Hitagi"}
-
- This change is consider a stopgap as we cannot change the code to stop
- `ActionController::Parameters` to inherit from `HashWithIndifferentAccess`
- in the next minor release.
-
- *Prem Sichanugrist*
-
-* Deprecated `TagAssertions`.
-
- *Kasper Timm Hansen*
-
-* Use the Active Support JSON encoder for cookie jars using the `:json` or
- `:hybrid` serializer. This allows you to serialize custom Ruby objects into
- cookies by defining the `#as_json` hook on such objects.
-
- Fixes #16520.
-
- *Godfrey Chan*
-
-* Add `config.action_dispatch.cookies_digest` option for setting custom
- digest. The default remains the same - 'SHA1'.
-
- *Łukasz Strzałkowski*
-
-* Move `respond_with` (and the class-level `respond_to`) to
- the `responders` gem.
-
- *José Valim*
-
-* When your templates change, browser caches bust automatically.
-
- New default: the template digest is automatically included in your ETags.
- When you call `fresh_when @post`, the digest for `posts/show.html.erb`
- is mixed in so future changes to the HTML will blow HTTP caches for you.
- This makes it easy to HTTP-cache many more of your actions.
-
- If you render a different template, you can now pass the `:template`
- option to include its digest instead:
-
- fresh_when @post, template: 'widgets/show'
-
- Pass `template: false` to skip the lookup. To turn this off entirely, set:
-
- config.action_controller.etag_with_template_digest = false
-
- *Jeremy Kemper*
-
-* Remove deprecated `AbstractController::Helpers::ClassMethods::MissingHelperError`
- in favor of `AbstractController::Helpers::MissingHelperError`.
-
- *Yves Senn*
-
-* Fix `assert_template` not being able to assert that no files were rendered.
-
- *Guo Xiang Tan*
-
-* Extract source code for the entire exception stack trace for
- better debugging and diagnosis.
-
- *Ryan Dao*
-
-* Allows ActionDispatch::Request::LOCALHOST to match any IPv4 127.0.0.0/8
- loopback address.
-
- *Earl St Sauver*, *Sven Riedel*
-
-* Preserve original path in `ShowExceptions` middleware by stashing it as
- `env["action_dispatch.original_path"]`
-
- `ActionDispatch::ShowExceptions` overwrites `PATH_INFO` with the status code
- for the exception defined in `ExceptionWrapper`, so the path
- the user was visiting when an exception occurred was not previously
- available to any custom exceptions_app. The original `PATH_INFO` is now
- stashed in `env["action_dispatch.original_path"]`.
-
- *Grey Baker*
-
-* Use `String#bytesize` instead of `String#size` when checking for cookie
- overflow.
-
- *Agis Anastasopoulos*
-
-* `render nothing: true` or rendering a `nil` body no longer add a single
- space to the response body.
-
- The old behavior was added as a workaround for a bug in an early version of
- Safari, where the HTTP headers are not returned correctly if the response
- body has a 0-length. This is been fixed since and the workaround is no
- longer necessary.
-
- Use `render body: ' '` if the old behavior is desired.
-
- See #14883 for details.
-
- *Godfrey Chan*
-
-* Prepend a JS comment to JSONP callbacks. Addresses CVE-2014-4671
- ("Rosetta Flash").
-
- *Greg Campbell*
-
-* Because URI paths may contain non US-ASCII characters we need to force
- the encoding of any unescaped URIs to UTF-8 if they are US-ASCII.
- This essentially replicates the functionality of the monkey patch to
- URI.parser.unescape in active_support/core_ext/uri.rb.
-
- Fixes #16104.
-
- *Karl Entwistle*
-
-* Generate shallow paths for all children of shallow resources.
-
- Fixes #15783.
-
- *Seb Jacobs*
-
-* JSONP responses are now rendered with the `text/javascript` content type
- when rendering through a `respond_to` block.
-
- Fixes #15081.
-
- *Lucas Mazza*
-
-* Add `config.action_controller.always_permitted_parameters` to configure which
- parameters are permitted globally. The default value of this configuration is
- `['controller', 'action']`.
-
- *Gary S. Weaver*, *Rafael Chacon*
-
-* Fix env['PATH_INFO'] missing leading slash when a rack app mounted at '/'.
-
- Fixes #15511.
-
- *Larry Lv*
-
-* ActionController::Parameters#require now accepts `false` values.
-
- Fixes #15685.
-
- *Sergio Romano*
-
-* With authorization header `Authorization: Token token=`, `authenticate` now
- recognize token as nil, instead of "token".
-
- Fixes #14846.
-
- *Larry Lv*
-
-* Ensure the controller is always notified as soon as the client disconnects
- during live streaming, even when the controller is blocked on a write.
-
- *Nicholas Jakobsen*, *Matthew Draper*
-
-* Routes specifying 'to:' must be a string that contains a "#" or a rack
- application. Use of a symbol should be replaced with `action: symbol`.
- Use of a string without a "#" should be replaced with `controller: string`.
-
- *Aaron Patterson*
-
-* Fix URL generation with `:trailing_slash` such that it does not add
- a trailing slash after `.:format`
-
- *Dan Langevin*
-
-* Build full URI as string when processing path in integration tests for
- performance reasons.
-
- *Guo Xiang Tan*
-
-* Fix `'Stack level too deep'` when rendering `head :ok` in an action method
- called 'status' in a controller.
-
- Fixes #13905.
-
- *Christiaan Van den Poel*
-
-* Add MKCALENDAR HTTP method (RFC 4791).
-
- *Sergey Karpesh*
-
-* Instrument fragment cache metrics.
-
- Adds `:controller`: and `:action` keys to the instrumentation payload
- for the `*_fragment.action_controller` notifications. This allows tracking
- e.g. the fragment cache hit rates for each controller action.
-
- *Daniel Schierbeck*
-
-* Always use the provided port if the protocol is relative.
-
- Fixes #15043.
-
- *Guilherme Cavalcanti*, *Andrew White*
-
-* Moved `params[request_forgery_protection_token]` into its own method
- and improved tests.
-
- Fixes #11316.
-
- *Tom Kadwill*
-
-* Added verification of route constraints given as a Proc or an object responding
- to `:matches?`. Previously, when given an non-complying object, it would just
- silently fail to enforce the constraint. It will now raise an `ArgumentError`
- when setting up the routes.
-
- *Xavier Defrang*
-
-* Properly treat the entire IPv6 User Local Address space as private for
- purposes of remote IP detection. Also handle uppercase private IPv6
- addresses.
-
- Fixes #12638.
-
- *Caleb Spare*
-
-* Fixed an issue with migrating legacy json cookies.
-
- Previously, the `VerifyAndUpgradeLegacySignedMessage` assumes all incoming
- cookies are marshal-encoded. This is not the case when `secret_token` is
- used in conjunction with the `:json` or `:hybrid` serializer.
-
- In those case, when upgrading to use `secret_key_base`, this would cause a
- `TypeError: incompatible marshal file format` and a 500 error for the user.
-
- Fixes #14774.
-
- *Godfrey Chan*
-
-* Make URL escaping more consistent:
-
- 1. Escape '%' characters in URLs - only unescaped data should be passed to URL helpers
- 2. Add an `escape_segment` helper to `Router::Utils` that escapes '/' characters
- 3. Use `escape_segment` rather than `escape_fragment` in optimized URL generation
- 4. Use `escape_segment` rather than `escape_path` in URL generation
-
- For point 4 there are two exceptions. Firstly, when a route uses wildcard segments
- (e.g. `*foo`) then we use `escape_path` as the value may contain '/' characters. This
- means that wildcard routes can't be optimized. Secondly, if a `:controller` segment
- is used in the path then this uses `escape_path` as the controller may be namespaced.
-
- Fixes #14629, #14636 and #14070.
-
- *Andrew White*, *Edho Arief*
-
-* Add alias `ActionDispatch::Http::UploadedFile#to_io` to
- `ActionDispatch::Http::UploadedFile#tempfile`.
-
- *Tim Linquist*
-
-* Returns null type format when format is not know and controller is using `any`
- format block.
-
- Fixes #14462.
-
- *Rafael Mendonça França*
-
-* Improve routing error page with fuzzy matching search.
-
- *Winston*
-
-* Only make deeply nested routes shallow when parent is shallow.
-
- Fixes #14684.
-
- *Andrew White*, *James Coglan*
-
-* Append link to bad code to backtrace when exception is `SyntaxError`.
-
- *Boris Kuznetsov*
-
-* Swapped the parameters of assert_equal in `assert_select` so that the
- proper values were printed correctly.
-
- Fixes #14422.
-
- *Vishal Lal*
-
-* The method `shallow?` returns false if the parent resource is a singleton so
- we need to check if we're not inside a nested scope before copying the :path
- and :as options to their shallow equivalents.
-
- Fixes #14388.
-
- *Andrew White*
-
-* Make logging of CSRF failures optional (but on by default) with the
- `log_warning_on_csrf_failure` configuration setting in
- `ActionController::RequestForgeryProtection`.
-
- *John Barton*
-
-* Fix URL generation in controller tests with request-dependent
- `default_url_options` methods.
-
- *Tony Wooster*
-
-Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/actionpack/CHANGELOG.md) for previous changes.
+Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/actionpack/CHANGELOG.md) for previous changes.
diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec
index 0a49a653d9..0f5880c1a7 100644
--- a/actionpack/actionpack.gemspec
+++ b/actionpack/actionpack.gemspec
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.summary = 'Web-flow and rendering framework putting the VC in MVC (part of Rails).'
s.description = 'Web apps on Rails. Simple, battle-tested conventions for building and testing MVC web applications. Works with any Rack-compatible server.'
- s.required_ruby_version = '>= 1.9.3'
+ s.required_ruby_version = '>= 2.1.0'
s.license = 'MIT'
diff --git a/actionpack/lib/abstract_controller/base.rb b/actionpack/lib/abstract_controller/base.rb
index 4026dab2ce..51c661f735 100644
--- a/actionpack/lib/abstract_controller/base.rb
+++ b/actionpack/lib/abstract_controller/base.rb
@@ -82,7 +82,7 @@ module AbstractController
# Except for public instance methods of Base and its ancestors
internal_methods +
# Be sure to include shadowed public instance methods of this class
- public_instance_methods(false)).uniq.map { |x| x.to_s } -
+ public_instance_methods(false)).uniq.map(&:to_s) -
# And always exclude explicitly hidden actions
hidden_actions.to_a
diff --git a/actionpack/lib/action_controller/metal/testing.rb b/actionpack/lib/action_controller/metal/testing.rb
index dd8da4b5dc..d01927b7cb 100644
--- a/actionpack/lib/action_controller/metal/testing.rb
+++ b/actionpack/lib/action_controller/metal/testing.rb
@@ -24,7 +24,7 @@ module ActionController
module ClassMethods
def before_filters
- _process_action_callbacks.find_all{|x| x.kind == :before}.map{|x| x.name}
+ _process_action_callbacks.find_all{|x| x.kind == :before}.map(&:name)
end
end
end
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb
index b9d5009683..047a17937a 100644
--- a/actionpack/lib/action_dispatch/http/mime_type.rb
+++ b/actionpack/lib/action_dispatch/http/mime_type.rb
@@ -6,7 +6,7 @@ require 'active_support/core_ext/string/starts_ends_with'
module Mime
class Mimes < Array
def symbols
- @symbols ||= map { |m| m.to_sym }
+ @symbols ||= map(&:to_sym)
end
%w(<< concat shift unshift push pop []= clear compact! collect!
diff --git a/actionpack/lib/action_dispatch/journey/nfa/transition_table.rb b/actionpack/lib/action_dispatch/journey/nfa/transition_table.rb
index 66e414213a..e65f7238ab 100644
--- a/actionpack/lib/action_dispatch/journey/nfa/transition_table.rb
+++ b/actionpack/lib/action_dispatch/journey/nfa/transition_table.rb
@@ -107,7 +107,7 @@ module ActionDispatch
end
def alphabet
- inverted.values.flat_map(&:keys).compact.uniq.sort_by { |x| x.to_s }
+ inverted.values.flat_map(&:keys).compact.uniq.sort_by(&:to_s)
end
# Returns a set of NFA states reachable from some NFA state +s+ in set
diff --git a/actionpack/lib/action_dispatch/journey/path/pattern.rb b/actionpack/lib/action_dispatch/journey/path/pattern.rb
index 3af940a02f..dca83e806c 100644
--- a/actionpack/lib/action_dispatch/journey/path/pattern.rb
+++ b/actionpack/lib/action_dispatch/journey/path/pattern.rb
@@ -42,7 +42,7 @@ module ActionDispatch
end
def names
- @names ||= spec.grep(Nodes::Symbol).map { |n| n.name }
+ @names ||= spec.grep(Nodes::Symbol).map(&:name)
end
def required_names
@@ -52,7 +52,7 @@ module ActionDispatch
def optional_names
@optional_names ||= spec.grep(Nodes::Group).flat_map { |group|
group.grep(Nodes::Symbol)
- }.map { |n| n.name }.uniq
+ }.map(&:name).uniq
end
class RegexpOffsets < Journey::Visitors::Visitor # :nodoc:
diff --git a/actionpack/lib/action_dispatch/journey/route.rb b/actionpack/lib/action_dispatch/journey/route.rb
index 9f0a3af902..3b609a184d 100644
--- a/actionpack/lib/action_dispatch/journey/route.rb
+++ b/actionpack/lib/action_dispatch/journey/route.rb
@@ -60,7 +60,7 @@ module ActionDispatch
end
def parts
- @parts ||= segments.map { |n| n.to_sym }
+ @parts ||= segments.map(&:to_sym)
end
alias :segment_keys :parts
@@ -69,11 +69,11 @@ module ActionDispatch
end
def optional_parts
- path.optional_names.map { |n| n.to_sym }
+ path.optional_names.map(&:to_sym)
end
def required_parts
- @required_parts ||= path.required_names.map { |n| n.to_sym }
+ @required_parts ||= path.required_names.map(&:to_sym)
end
def required_default?(key)
diff --git a/actionpack/lib/action_dispatch/journey/router.rb b/actionpack/lib/action_dispatch/journey/router.rb
index 9131b65380..2b036796ab 100644
--- a/actionpack/lib/action_dispatch/journey/router.rb
+++ b/actionpack/lib/action_dispatch/journey/router.rb
@@ -68,8 +68,8 @@ module ActionDispatch
def visualizer
tt = GTG::Builder.new(ast).transition_table
- groups = partitioned_routes.first.map(&:ast).group_by { |a| a.to_s }
- asts = groups.values.map { |v| v.first }
+ groups = partitioned_routes.first.map(&:ast).group_by(&:to_s)
+ asts = groups.values.map(&:first)
tt.visualizer(asts)
end
diff --git a/actionpack/lib/action_dispatch/routing/inspector.rb b/actionpack/lib/action_dispatch/routing/inspector.rb
index cfe2237512..df5ebb6751 100644
--- a/actionpack/lib/action_dispatch/routing/inspector.rb
+++ b/actionpack/lib/action_dispatch/routing/inspector.rb
@@ -114,9 +114,7 @@ module ActionDispatch
def collect_routes(routes)
routes.collect do |route|
RouteWrapper.new(route)
- end.reject do |route|
- route.internal?
- end.collect do |route|
+ end.reject(&:internal?).collect do |route|
collect_engine_routes(route)
{ name: route.name,
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 6e3ae36a7f..c2cacbd288 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -543,7 +543,7 @@ module ActionDispatch
path = conditions.delete :path_info
ast = conditions.delete :parsed_path_info
path = build_path(path, ast, requirements, anchor)
- conditions = build_conditions(conditions, path.names.map { |x| x.to_sym })
+ conditions = build_conditions(conditions, path.names.map(&:to_sym))
route = @set.add_route(app, path, conditions, defaults, name)
named_routes[name] = route if name
@@ -605,7 +605,7 @@ module ActionDispatch
if name == :controller
value
elsif value.is_a?(Array)
- value.map { |v| v.to_param }.join('/')
+ value.map(&:to_param).join('/')
elsif param = value.to_param
param
end
diff --git a/actionpack/lib/action_dispatch/testing/test_request.rb b/actionpack/lib/action_dispatch/testing/test_request.rb
index de3dc5f924..4b9a088265 100644
--- a/actionpack/lib/action_dispatch/testing/test_request.rb
+++ b/actionpack/lib/action_dispatch/testing/test_request.rb
@@ -60,7 +60,7 @@ module ActionDispatch
def accept=(mime_types)
@env.delete('action_dispatch.request.accepts')
- @env['HTTP_ACCEPT'] = Array(mime_types).collect { |mime_type| mime_type.to_s }.join(",")
+ @env['HTTP_ACCEPT'] = Array(mime_types).collect(&:to_s).join(",")
end
alias :rack_cookies :cookies
diff --git a/actionpack/lib/action_pack/gem_version.rb b/actionpack/lib/action_pack/gem_version.rb
index 9b3ea30f69..255ac9f4ed 100644
--- a/actionpack/lib/action_pack/gem_version.rb
+++ b/actionpack/lib/action_pack/gem_version.rb
@@ -5,10 +5,10 @@ module ActionPack
end
module VERSION
- MAJOR = 4
- MINOR = 2
+ MAJOR = 5
+ MINOR = 0
TINY = 0
- PRE = "beta4"
+ PRE = "alpha"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 63c9ab04c9..57c076eac6 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -53,7 +53,7 @@ I18n.enforce_available_locales = false
# Register danish language for testing
I18n.backend.store_translations 'da', {}
I18n.backend.store_translations 'pt-BR', {}
-ORIGINAL_LOCALES = I18n.available_locales.map {|locale| locale.to_s }.sort
+ORIGINAL_LOCALES = I18n.available_locales.map(&:to_s).sort
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
FIXTURES = Pathname.new(FIXTURE_LOAD_PATH)
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb
index b2b01b3fa9..38533dbf23 100644
--- a/actionpack/test/controller/filters_test.rb
+++ b/actionpack/test/controller/filters_test.rb
@@ -10,7 +10,7 @@ class ActionController::Base
def before_actions
filters = _process_action_callbacks.select { |c| c.kind == :before }
- filters.map! { |c| c.raw_filter }
+ filters.map!(&:raw_filter)
end
end
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index f46b32e019..9caa5cbe57 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -884,13 +884,13 @@ class RouteSetTest < ActiveSupport::TestCase
set.draw { get ':controller/(:action(/:id))' }
path, extras = set.generate_extras(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")
assert_equal "/foo/bar/15", path
- assert_equal %w(that this), extras.map { |e| e.to_s }.sort
+ assert_equal %w(that this), extras.map(&:to_s).sort
end
def test_extra_keys
set.draw { get ':controller/:action/:id' }
extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")
- assert_equal %w(that this), extras.map { |e| e.to_s }.sort
+ assert_equal %w(that this), extras.map(&:to_s).sort
end
def test_generate_extras_not_first
@@ -900,7 +900,7 @@ class RouteSetTest < ActiveSupport::TestCase
end
path, extras = set.generate_extras(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")
assert_equal "/foo/bar/15", path
- assert_equal %w(that this), extras.map { |e| e.to_s }.sort
+ assert_equal %w(that this), extras.map(&:to_s).sort
end
def test_generate_not_first
@@ -918,7 +918,7 @@ class RouteSetTest < ActiveSupport::TestCase
get ':controller/:action/:id'
end
extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")
- assert_equal %w(that this), extras.map { |e| e.to_s }.sort
+ assert_equal %w(that this), extras.map(&:to_s).sort
end
def test_draw
diff --git a/actionpack/test/dispatch/mime_type_test.rb b/actionpack/test/dispatch/mime_type_test.rb
index ad6335f132..3017a9c2d6 100644
--- a/actionpack/test/dispatch/mime_type_test.rb
+++ b/actionpack/test/dispatch/mime_type_test.rb
@@ -83,7 +83,7 @@ class MimeTypeTest < ActiveSupport::TestCase
test "parse broken acceptlines" do
accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/*,,*/*;q=0.5"
expect = [Mime::HTML, Mime::XML, "image/*", Mime::TEXT, Mime::ALL]
- assert_equal expect, Mime::Type.parse(accept).collect { |c| c.to_s }
+ assert_equal expect, Mime::Type.parse(accept).collect(&:to_s)
end
# Accept header send with user HTTP_USER_AGENT: Mozilla/4.0
@@ -91,7 +91,7 @@ class MimeTypeTest < ActiveSupport::TestCase
test "parse other broken acceptlines" do
accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, , pronto/1.00.00, sslvpn/1.00.00.00, */*"
expect = ['image/gif', 'image/x-xbitmap', 'image/jpeg','image/pjpeg', 'application/x-shockwave-flash', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/msword', 'pronto/1.00.00', 'sslvpn/1.00.00.00', Mime::ALL]
- assert_equal expect, Mime::Type.parse(accept).collect { |c| c.to_s }
+ assert_equal expect, Mime::Type.parse(accept).collect(&:to_s)
end
test "custom type" do
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md
index de65543137..729717608f 100644
--- a/actionview/CHANGELOG.md
+++ b/actionview/CHANGELOG.md
@@ -1,218 +1 @@
-* 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*
-
-* Add support for `:enforce_utf8` option in `form_for`.
-
- This is the same option that was added in 06388b0 to `form_tag` and allows
- users to skip the insertion of the UTF8 enforcer tag in a form.
-
- * claudiob *
-
-* Fix a bug that <%= foo(){ %> and <%= foo()do %> in view templates were not regarded
- as Ruby block calls.
-
- * Akira Matsuda *
-
-* Update `select_tag` to work correctly with `:include_blank` option passing a string.
-
- Fixes #16483.
-
- *Frank Groeneveld*
-
-* Changed the meaning of `render "foo/bar"`.
-
- Previously, calling `render "foo/bar"` in a controller action is equivalent
- to `render file: "foo/bar"`. In Rails 4.2, this has been changed to mean
- `render template: "foo/bar"` instead. If you need to render a file, please
- change your code to use the explicit form (`render file: "foo/bar"`) instead.
-
- *Jeremy Jackson*
-
-* Add support for ARIA attributes in tags.
-
- Example:
-
- <%= f.text_field :name, aria: { required: "true", hidden: "false" } %>
-
- now generates:
-
- <input aria-hidden="false" aria-required="true" id="user_name" name="user[name]" type="text">
-
- *Paola Garcia Casadiego*
-
-* Provide a `builder` object when using the `label` form helper in block form.
-
- The new `builder` object responds to `translation`, allowing I18n fallback support
- when you want to customize how a particular label is presented.
-
- *Alex Robbin*
-
-* Add I18n support for input/textarea placeholder text.
-
- Placeholder I18n follows the same convention as `label` I18n.
-
- *Alex Robbin*
-
-* Fix that render layout: 'messages/layout' should also be added to the dependency tracker tree.
-
- *DHH*
-
-* Add `PartialIteration` object used when rendering collections.
-
- The iteration object is available as the local variable
- `#{template_name}_iteration` when rendering partials with collections.
-
- It gives access to the `size` of the collection being iterated over,
- the current `index` and two convenience methods `first?` and `last?`.
-
- *Joel Junström*, *Lucas Uyezu*
-
-* Return an absolute instead of relative path from an asset url in the case
- of the `asset_host` proc returning nil.
-
- *Jolyon Pawlyn*
-
-* Fix `html_escape_once` to properly handle hex escape sequences (e.g. &#x1a2b;).
-
- *John F. Douthat*
-
-* Added String support for min and max properties for date field helpers.
-
- *Todd Bealmear*
-
-* The `highlight` helper now accepts a block to be used instead of the `highlighter`
- option.
-
- *Lucas Mazza*
-
-* The `except` and `highlight` helpers now accept regular expressions.
-
- *Jan Szumiec*
-
-* Flatten the array parameter in `safe_join`, so it behaves consistently with
- `Array#join`.
-
- *Paul Grayson*
-
-* Honor `html_safe` on array elements in tag values, as we do for plain string
- values.
-
- *Paul Grayson*
-
-* Add `ActionView::Template::Handler.unregister_template_handler`.
-
- It performs the opposite of `ActionView::Template::Handler.register_template_handler`.
-
- *Zuhao Wan*
-
-* Bring `cache_digest` rake tasks up-to-date with the latest API changes.
-
- *Jiri Pospisil*
-
-* Allow custom `:host` option to be passed to `asset_url` helper that
- overwrites `config.action_controller.asset_host` for particular asset.
-
- *Hubert Łępicki*
-
-* Deprecate `AbstractController::Base.parent_prefixes`.
- Override `AbstractController::Base.local_prefixes` when you want to change
- where to find views.
-
- *Nick Sutterer*
-
-* Take label values into account when doing I18n lookups for model attributes.
-
- The following:
-
- # form.html.erb
- <%= form_for @post do |f| %>
- <%= f.label :type, value: "long" %>
- <% end %>
-
- # en.yml
- en:
- activerecord:
- attributes:
- post/long: "Long-form Post"
-
- Used to simply return "long", but now it will return "Long-form
- Post".
-
- *Joshua Cody*
-
-* Change `asset_path` to use File.join to create proper paths:
-
- Before:
-
- https://some.host.com//assets/some.js
-
- After:
-
- https://some.host.com/assets/some.js
-
- *Peter Schröder*
-
-* Change `favicon_link_tag` default mimetype from `image/vnd.microsoft.icon` to
- `image/x-icon`.
-
- Before:
-
- # => favicon_link_tag 'myicon.ico'
- <link href="/assets/myicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
-
- After:
-
- # => favicon_link_tag 'myicon.ico'
- <link href="/assets/myicon.ico" rel="shortcut icon" type="image/x-icon" />
-
- *Geoffroy Lorieux*
-
-* Remove wrapping div with inline styles for hidden form fields.
-
- We are dropping HTML 4.01 and XHTML strict compliance since input tags directly
- inside a form are valid HTML5, and the absence of inline styles help in validating
- for Content Security Policy.
-
- *Joost Baaij*
-
-* `collection_check_boxes` respects `:index` option for the hidden field name.
-
- Fixes #14147.
-
- *Vasiliy Ermolovich*
-
-* `date_select` helper with option `with_css_classes: true` does not overwrite other classes.
-
- *Izumi Wong-Horiuchi*
-
-* `number_to_percentage` does not crash with `Float::NAN` or `Float::INFINITY`
- as input.
-
- Fixes #14405.
-
- *Yves Senn*
-
-* Add `include_hidden` option to `collection_check_boxes` helper.
-
- *Vasiliy Ermolovich*
-
-* Fixed a problem where the default options for the `button_tag` helper are not
- applied correctly.
-
- Fixes #14254.
-
- *Sergey Prikhodko*
-
-* Take variants into account when calculating template digests in ActionView::Digestor.
-
- The arguments to ActionView::Digestor#digest are now being passed as a hash
- to support variants and allow more flexibility in the future. The support for
- regular (required) arguments is deprecated and will be removed in Rails 5.0 or later.
-
- *Piotr Chmolowski, Łukasz Strzałkowski*
-
-Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/actionview/CHANGELOG.md) for previous changes.
+Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/actionview/CHANGELOG.md) for previous changes.
diff --git a/actionview/actionview.gemspec b/actionview/actionview.gemspec
index 28407521cc..fd4ffea33d 100644
--- a/actionview/actionview.gemspec
+++ b/actionview/actionview.gemspec
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.summary = 'Rendering framework putting the V in MVC (part of Rails).'
s.description = 'Simple, battle-tested conventions and helpers for building web pages.'
- s.required_ruby_version = '>= 1.9.3'
+ s.required_ruby_version = '>= 2.1.0'
s.license = 'MIT'
diff --git a/actionview/lib/action_view/base.rb b/actionview/lib/action_view/base.rb
index 3071a13655..1feafc1094 100644
--- a/actionview/lib/action_view/base.rb
+++ b/actionview/lib/action_view/base.rb
@@ -126,8 +126,8 @@ module ActionView #:nodoc:
# end
# end
#
- # For more information on Builder please consult the [source
- # code](https://github.com/jimweirich/builder).
+ # For more information on Builder please consult the {source
+ # code}[https://github.com/jimweirich/builder].
class Base
include Helpers, ::ERB::Util, Context
diff --git a/actionview/lib/action_view/gem_version.rb b/actionview/lib/action_view/gem_version.rb
index 752eafee3c..4f45f5b8c8 100644
--- a/actionview/lib/action_view/gem_version.rb
+++ b/actionview/lib/action_view/gem_version.rb
@@ -5,10 +5,10 @@ module ActionView
end
module VERSION
- MAJOR = 4
- MINOR = 2
+ MAJOR = 5
+ MINOR = 0
TINY = 0
- PRE = "beta4"
+ PRE = "alpha"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end
diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb
index bd7b36c352..4b4f0ae577 100644
--- a/actionview/lib/action_view/helpers/date_helper.rb
+++ b/actionview/lib/action_view/helpers/date_helper.rb
@@ -898,7 +898,7 @@ module ActionView
def translated_date_order
date_order = I18n.translate(:'date.order', :locale => @options[:locale], :default => [])
- date_order = date_order.map { |element| element.to_sym }
+ date_order = date_order.map(&:to_sym)
forbidden_elements = date_order - [:year, :month, :day]
if forbidden_elements.any?
diff --git a/actionview/lib/action_view/helpers/form_options_helper.rb b/actionview/lib/action_view/helpers/form_options_helper.rb
index 83b07a00d4..bbfbf482a4 100644
--- a/actionview/lib/action_view/helpers/form_options_helper.rb
+++ b/actionview/lib/action_view/helpers/form_options_helper.rb
@@ -351,12 +351,12 @@ module ActionView
return container if String === container
selected, disabled = extract_selected_and_disabled(selected).map do |r|
- Array(r).map { |item| item.to_s }
+ Array(r).map(&:to_s)
end
container.map do |element|
html_attributes = option_html_attributes(element)
- text, value = option_text_and_value(element).map { |item| item.to_s }
+ text, value = option_text_and_value(element).map(&:to_s)
html_attributes[:selected] ||= option_value_selected?(value, selected)
html_attributes[:disabled] ||= disabled && option_value_selected?(value, disabled)
diff --git a/actionview/lib/action_view/helpers/tag_helper.rb b/actionview/lib/action_view/helpers/tag_helper.rb
index b2038576a2..a87c223a71 100644
--- a/actionview/lib/action_view/helpers/tag_helper.rb
+++ b/actionview/lib/action_view/helpers/tag_helper.rb
@@ -18,7 +18,7 @@ module ActionView
itemscope allowfullscreen default inert sortable
truespeed typemustmatch).to_set
- BOOLEAN_ATTRIBUTES.merge(BOOLEAN_ATTRIBUTES.map {|attribute| attribute.to_sym })
+ BOOLEAN_ATTRIBUTES.merge(BOOLEAN_ATTRIBUTES.map(&:to_sym))
TAG_PREFIXES = ['aria', 'data', :aria, :data].to_set
diff --git a/actionview/lib/action_view/layouts.rb b/actionview/lib/action_view/layouts.rb
index 9ee05bd816..0b5c0b9991 100644
--- a/actionview/lib/action_view/layouts.rb
+++ b/actionview/lib/action_view/layouts.rb
@@ -262,7 +262,7 @@ module ActionView
def layout(layout, conditions = {})
include LayoutConditions unless conditions.empty?
- conditions.each {|k, v| conditions[k] = Array(v).map {|a| a.to_s} }
+ conditions.each {|k, v| conditions[k] = Array(v).map(&:to_s) }
self._layout_conditions = conditions
self._layout = layout
diff --git a/actionview/lib/action_view/template/error.rb b/actionview/lib/action_view/template/error.rb
index 743ef6de0a..390bce98a2 100644
--- a/actionview/lib/action_view/template/error.rb
+++ b/actionview/lib/action_view/template/error.rb
@@ -75,7 +75,7 @@ module ActionView
def sub_template_message
if @sub_templates
"Trace of template inclusion: " +
- @sub_templates.collect { |template| template.inspect }.join(", ")
+ @sub_templates.collect(&:inspect).join(", ")
else
""
end
diff --git a/actionview/lib/action_view/template/handlers.rb b/actionview/lib/action_view/template/handlers.rb
index ff2feb5149..9e61ea4225 100644
--- a/actionview/lib/action_view/template/handlers.rb
+++ b/actionview/lib/action_view/template/handlers.rb
@@ -42,7 +42,7 @@ module ActionView #:nodoc:
end
def template_handler_extensions
- @@template_handlers.keys.map {|key| key.to_s }.sort
+ @@template_handlers.keys.map(&:to_s).sort
end
def registered_template_handler(extension)
diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb
index b65507f4a2..29d2e9ca90 100644
--- a/actionview/lib/action_view/template/resolver.rb
+++ b/actionview/lib/action_view/template/resolver.rb
@@ -139,7 +139,7 @@ module ActionView
# resolver is fresher before returning it.
def cached(key, path_info, details, locals) #:nodoc:
name, prefix, partial = path_info
- locals = locals.map { |x| x.to_s }.sort!
+ locals = locals.map(&:to_s).sort!
if key
@cache.cache(key, name, prefix, partial, locals) do
diff --git a/actionview/lib/action_view/template/types.rb b/actionview/lib/action_view/template/types.rb
index b84e0281ae..be45fcf742 100644
--- a/actionview/lib/action_view/template/types.rb
+++ b/actionview/lib/action_view/template/types.rb
@@ -9,7 +9,7 @@ module ActionView
self.types = Set.new
def self.register(*t)
- types.merge(t.map { |type| type.to_s })
+ types.merge(t.map(&:to_s))
end
register :html, :text, :js, :css, :xml, :json
diff --git a/actionview/test/abstract_unit.rb b/actionview/test/abstract_unit.rb
index 7096d588b6..4aa56f60f7 100644
--- a/actionview/test/abstract_unit.rb
+++ b/actionview/test/abstract_unit.rb
@@ -46,7 +46,7 @@ I18n.enforce_available_locales = false
# Register danish language for testing
I18n.backend.store_translations 'da', {}
I18n.backend.store_translations 'pt-BR', {}
-ORIGINAL_LOCALES = I18n.available_locales.map {|locale| locale.to_s }.sort
+ORIGINAL_LOCALES = I18n.available_locales.map(&:to_s).sort
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
FIXTURES = Pathname.new(FIXTURE_LOAD_PATH)
diff --git a/actionview/test/actionpack/controller/view_paths_test.rb b/actionview/test/actionpack/controller/view_paths_test.rb
index c6e7a523b9..7fba9ff8ff 100644
--- a/actionview/test/actionpack/controller/view_paths_test.rb
+++ b/actionview/test/actionpack/controller/view_paths_test.rb
@@ -39,7 +39,7 @@ class ViewLoadPathsTest < ActionController::TestCase
def assert_paths(*paths)
controller = paths.first.is_a?(Class) ? paths.shift : @controller
- assert_equal expand(paths), controller.view_paths.map { |p| p.to_s }
+ assert_equal expand(paths), controller.view_paths.map(&:to_s)
end
def test_template_load_path_was_set_correctly
diff --git a/actionview/test/template/erb_util_test.rb b/actionview/test/template/erb_util_test.rb
index 3bb84cbc50..3e72be31de 100644
--- a/actionview/test/template/erb_util_test.rb
+++ b/actionview/test/template/erb_util_test.rb
@@ -84,7 +84,7 @@ class ErbUtilTest < ActiveSupport::TestCase
end
def test_rest_in_ascii
- (0..127).to_a.map {|int| int.chr }.each do |chr|
+ (0..127).to_a.map(&:chr).each do |chr|
next if %('"&<>).include?(chr)
assert_equal chr, html_escape(chr)
end
diff --git a/actionview/test/template/render_test.rb b/actionview/test/template/render_test.rb
index 85817119ba..4e502bede9 100644
--- a/actionview/test/template/render_test.rb
+++ b/actionview/test/template/render_test.rb
@@ -16,7 +16,7 @@ module RenderTestCases
I18n.backend.store_translations 'pt-BR', {}
# Ensure original are still the same since we are reindexing view paths
- assert_equal ORIGINAL_LOCALES, I18n.available_locales.map {|l| l.to_s }.sort
+ assert_equal ORIGINAL_LOCALES, I18n.available_locales.map(&:to_s).sort
end
def test_render_without_options
diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md
index b04883413e..f9c481998e 100644
--- a/activejob/CHANGELOG.md
+++ b/activejob/CHANGELOG.md
@@ -1 +1 @@
-* Started project. \ No newline at end of file
+Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activejob/CHANGELOG.md) for previous changes.
diff --git a/activejob/activejob.gemspec b/activejob/activejob.gemspec
index a9be2a8f00..f6c8bc1682 100644
--- a/activejob/activejob.gemspec
+++ b/activejob/activejob.gemspec
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.summary = 'Job framework with pluggable queues.'
s.description = 'Declare job classes that can be run by a variety of queueing backends.'
- s.required_ruby_version = '>= 1.9.3'
+ s.required_ruby_version = '>= 2.1.0'
s.license = 'MIT'
diff --git a/activejob/lib/active_job/gem_version.rb b/activejob/lib/active_job/gem_version.rb
index ac364f77d1..27a5de93f4 100644
--- a/activejob/lib/active_job/gem_version.rb
+++ b/activejob/lib/active_job/gem_version.rb
@@ -5,10 +5,10 @@ module ActiveJob
end
module VERSION
- MAJOR = 4
- MINOR = 2
+ MAJOR = 5
+ MINOR = 0
TINY = 0
- PRE = "beta4"
+ PRE = "alpha"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end
diff --git a/activejob/test/support/delayed_job/delayed/backend/test.rb b/activejob/test/support/delayed_job/delayed/backend/test.rb
index b50ed36fc2..f80ec3a5a6 100644
--- a/activejob/test/support/delayed_job/delayed/backend/test.rb
+++ b/activejob/test/support/delayed_job/delayed/backend/test.rb
@@ -43,9 +43,7 @@ module Delayed
end
def self.create(attrs = {})
- new(attrs).tap do |o|
- o.save
- end
+ new(attrs).tap(&:save)
end
def self.create!(*args); create(*args); end
diff --git a/activejob/test/support/integration/adapters/sidekiq.rb b/activejob/test/support/integration/adapters/sidekiq.rb
index 3cc9a34993..bdc61a1462 100644
--- a/activejob/test/support/integration/adapters/sidekiq.rb
+++ b/activejob/test/support/integration/adapters/sidekiq.rb
@@ -48,7 +48,7 @@ module SidekiqJobsManager
def can_run?
begin
- Sidekiq.redis { |conn| conn.connect }
+ Sidekiq.redis(&:connect)
rescue
return false
end
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md
index 5588699d9b..b86e988841 100644
--- a/activemodel/CHANGELOG.md
+++ b/activemodel/CHANGELOG.md
@@ -1,61 +1 @@
-* Passwords with spaces only allowed in `ActiveModel::SecurePassword`.
-
- Presence validation can be used to restore old behavior.
-
- *Yevhene Shemet*
-
-* Validate options passed to `ActiveModel::Validations.validate`.
-
- Preventing, in many cases, the simple mistake of using `validate` instead of `validates`.
-
- *Sonny Michaud*
-
-* Deprecate `reset_#{attribute}` in favor of `restore_#{attribute}`.
-
- These methods may cause confusion with the `reset_changes`, which has
- different behaviour.
-
- *Rafael Mendonça França*
-
-* Deprecate `ActiveModel::Dirty#reset_changes` in favor of `#clear_changes_information`.
-
- Method's name is causing confusion with the `reset_#{attribute}` methods.
- While `reset_name` sets the value of the name attribute to previous value
- `reset_changes` only discards the changes.
-
- *Rafael Mendonça França*
-
-* Added `restore_attributes` method to `ActiveModel::Dirty` API which restores
- the value of changed attributes to previous value.
-
- *Igor G.*
-
-* Allow proc and symbol as values for `only_integer` of `NumericalityValidator`
-
- *Robin Mehner*
-
-* `has_secure_password` now verifies that the given password is less than 72
- characters if validations are enabled.
-
- Fixes #14591.
-
- *Akshay Vishnoi*
-
-* Remove deprecated `Validator#setup` without replacement.
-
- See #10716.
-
- *Kuldeep Aggarwal*
-
-* Add plural and singular form for length validator's default messages.
-
- *Abd ar-Rahman Hamid*
-
-* Introduce `validate` as an alias for `valid?`.
-
- This is more intuitive when you want to run validations but don't care about
- the return value.
-
- *Henrik Nyh*
-
-Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activemodel/CHANGELOG.md) for previous changes.
+Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activemodel/CHANGELOG.md) for previous changes.
diff --git a/activemodel/activemodel.gemspec b/activemodel/activemodel.gemspec
index 36e565f692..73600b83fb 100644
--- a/activemodel/activemodel.gemspec
+++ b/activemodel/activemodel.gemspec
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.summary = 'A toolkit for building modeling frameworks (part of Rails).'
s.description = 'A toolkit for building modeling frameworks like Active Record. Rich support for attributes, callbacks, validations, serialization, internationalization, and testing.'
- s.required_ruby_version = '>= 1.9.3'
+ s.required_ruby_version = '>= 2.1.0'
s.license = 'MIT'
diff --git a/activemodel/lib/active_model/gem_version.rb b/activemodel/lib/active_model/gem_version.rb
index 932fe3e5a9..2403242ce6 100644
--- a/activemodel/lib/active_model/gem_version.rb
+++ b/activemodel/lib/active_model/gem_version.rb
@@ -5,10 +5,10 @@ module ActiveModel
end
module VERSION
- MAJOR = 4
- MINOR = 2
+ MAJOR = 5
+ MINOR = 0
TINY = 0
- PRE = "beta4"
+ PRE = "alpha"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end
diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb
index 3834d327ea..12a22f9c40 100644
--- a/activemodel/test/cases/validations/numericality_validation_test.rb
+++ b/activemodel/test/cases/validations/numericality_validation_test.rb
@@ -59,7 +59,7 @@ class NumericalityValidationTest < ActiveModel::TestCase
def test_validates_numericality_of_with_integer_only_and_proc_as_value
Topic.send(:define_method, :allow_only_integers?, lambda { false })
- Topic.validates_numericality_of :approved, only_integer: Proc.new {|topic| topic.allow_only_integers? }
+ Topic.validates_numericality_of :approved, only_integer: Proc.new(&:allow_only_integers?)
invalid!(NIL + BLANK + JUNK)
valid!(FLOATS + INTEGERS + BIGDECIMAL + INFINITY)
@@ -130,7 +130,7 @@ class NumericalityValidationTest < ActiveModel::TestCase
def test_validates_numericality_with_proc
Topic.send(:define_method, :min_approved, lambda { 5 })
- Topic.validates_numericality_of :approved, greater_than_or_equal_to: Proc.new {|topic| topic.min_approved }
+ Topic.validates_numericality_of :approved, greater_than_or_equal_to: Proc.new(&:min_approved)
invalid!([3, 4])
valid!([5, 6])
diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb
index de71bb6f42..98e0266d7e 100644
--- a/activemodel/test/cases/validations_test.rb
+++ b/activemodel/test/cases/validations_test.rb
@@ -282,7 +282,7 @@ class ValidationsTest < ActiveModel::TestCase
ActiveModel::Validations::FormatValidator,
ActiveModel::Validations::LengthValidator,
ActiveModel::Validations::PresenceValidator
- ], validators.map { |v| v.class }.sort_by { |c| c.to_s }
+ ], validators.map(&:class).sort_by(&:to_s)
end
def test_list_of_validators_will_be_empty_when_empty
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index a6ed8cdb06..38c5583708 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,1336 +1 @@
-* 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 is synchronized.
-
- Fixes #17171, #15787.
-
- *Yves Senn*
-
-* Change `reflections` public api to return the keys as String objects.
-
- Fixes #16928.
-
- *arthurnn*
-
-* 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*
-
-* Fix preloading of associations with a scope containing joins along with
- conditions on the joined association.
-
- *Siddharth Sharma*
-
-* Add `Table#name` to match `TableDefinition#name`.
-
- *Cody Cutrer*
-
-* 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*
-
-* `ActiveRecord::ReadOnlyRecord` now has a descriptive message.
-
- *Franky W.*
-
-* Fix preloading of associations which unscope a default scope.
-
- Fixes #11036.
-
- *Byron Bischoff*
-
-* Added SchemaDumper support for tables with jsonb columns.
-
- *Ted O'Meara*
-
-* Deprecate `sanitize_sql_hash_for_conditions` without replacement. Using a
- `Relation` for performing queries and updates is the prefered API.
-
- *Sean Griffin*
-
-* Queries now properly type cast values that are part of a join statement,
- even when using type decorators such as `serialize`.
-
- *Melanie Gilman & Sean Griffin*
-
-* MySQL enum type lookups, with values matching another type, no longer result
- in an endless loop.
-
- Fixes #17402.
-
- *Yves Senn*
-
-* Raise `ArgumentError` when the body of a scope is not callable.
-
- *Mauro George*
-
-* Use type column first in multi-column indexes created with `add-reference`.
-
- *Derek Prior*
-
-* Fix `Relation.rewhere` to work with Range values.
-
- *Dan Olson*
-
-* `AR::UnknownAttributeError` now includes the class name of a record.
-
- User.new(name: "Yuki Nishijima", project_attributes: {name: "kaminari"})
- # => ActiveRecord::UnknownAttributeError: unknown attribute 'name' for User.
-
- *Yuki Nishijima*
-
-* Fix a regression causing `after_create` callbacks to run before associated
- records are autosaved.
-
- Fixes #17209.
-
- *Agis Anastasopoulos*
-
-* Honor overridden `rack.test` in Rack environment for the connection
- management middleware.
-
- *Simon Eskildsen*
-
-* Add a truncate method to the connection.
-
- *Aaron Patterson*
-
-* Don't autosave unchanged has_one through records.
-
- *Alan Kennedy*, *Steve Parrington*
-
-* Do not dump foreign keys for ignored tables.
-
- *Yves Senn*
-
-* PostgreSQL adapter correctly dumps foreign keys targeting tables
- outside the schema search path.
-
- Fixes #16907.
-
- *Matthew Draper*, *Yves Senn*
-
-* When a thread is killed, rollback the active transaction, instead of
- committing it during the stack unwind. Previously, we could commit half-
- completed work. This fix only works for Ruby 2.0+; on 1.9, we can't
- distinguish a thread kill from an ordinary non-local (block) return, so must
- default to committing.
-
- *Chris Hanks*
-
-* A `NullRelation` should represent nothing. This fixes a bug where
- `Comment.where(post_id: Post.none)` returned a non-empty result.
-
- Fixes #15176.
-
- *Matthew Draper*, *Yves Senn*
-
-* Include default column limits in schema.rb. Allows defaults to be changed
- in the future without affecting old migrations that assumed old defaults.
-
- *Jeremy Kemper*
-
-* MySQL: schema.rb now includes TEXT and BLOB column limits.
-
- *Jeremy Kemper*
-
-* MySQL: correct LONGTEXT and LONGBLOB limits from 2GB to their true 4GB.
-
- *Jeremy Kemper*
-
-* SQLite3Adapter now checks for views in `table_exists?`. Fixes #14041.
-
- *Girish Sonawane*
-
-* Introduce `connection.supports_views?` to check whether the current adapter
- has support for SQL views. Connection adapters should define this method.
-
- *Yves Senn*
-
-* Allow included modules to override association methods.
-
- Fixes #16684.
-
- *Yves Senn*
-
-* Schema loading rake tasks (like `db:schema:load` and `db:setup`) maintain
- the database connection to the current environment.
-
- Fixes #16757.
-
- *Joshua Cody*, *Yves Senn*
-
-* MySQL: set the connection collation along with the charset.
-
- Sets the connection collation to the database collation configured in
- database.yml. Otherwise, `SET NAMES utf8mb4` will use the default
- collation for that charset (utf8mb4_general_ci) when you may have chosen
- a different collation, like utf8mb4_unicode_ci.
-
- This only applies to literal string comparisons, not column values, so it
- is unlikely to affect you.
-
- *Jeremy Kemper*
-
-* `default_sequence_name` from the PostgreSQL adapter returns a `String`.
-
- *Yves Senn*
-
-* Fix a regression where whitespaces were stripped from DISTINCT queries in
- PostgreSQL.
-
- *Agis Anastasopoulos*
-
- Fixes #16623.
-
-* Fix has_many :through relation merging failing when dynamic conditions are
- passed as a lambda with an arity of one.
-
- Fixes #16128.
-
- *Agis Anastasopoulos*
-
-* Fix `Relation#exists?` to work with polymorphic associations.
-
- Fixes #15821.
-
- *Kassio Borges*
-
-* Currently, Active Record rescues any errors raised within
- `after_rollback`/`after_create` callbacks and prints them to the logs.
- Future versions of Rails will not rescue these errors anymore and
- just bubble them up like the other callbacks.
-
- This commit adds an opt-in flag to enable not rescuing the errors.
-
- Example:
-
- # Do not swallow errors in after_commit/after_rollback callbacks.
- config.active_record.raise_in_transactional_callbacks = true
-
- Fixes #13460.
-
- *arthurnn*
-
-* Fix an issue where custom accessor methods (such as those generated by
- `enum`) with the same name as a global method are incorrectly overridden
- when subclassing.
-
- Fixes #16288.
-
- *Godfrey Chan*
-
-* `*_was` and `changes` now work correctly for in-place attribute changes as
- well.
-
- *Sean Griffin*
-
-* Fix regression on `after_commit` that did not fire with nested transactions.
-
- Fixes #16425.
-
- *arthurnn*
-
-* Do not try to write timestamps when a table has no timestamps columns.
-
- Fixes #8813.
-
- *Sergey Potapov*
-
-* `index_exists?` with `:name` option does verify specified columns.
-
- Example:
-
- add_index :articles, :title, name: "idx_title"
-
- # Before:
- index_exists? :articles, :title, name: "idx_title" # => `true`
- index_exists? :articles, :body, name: "idx_title" # => `true`
-
- # After:
- index_exists? :articles, :title, name: "idx_title" # => `true`
- index_exists? :articles, :body, name: "idx_title" # => `false`
-
- *Yves Senn*, *Matthew Draper*
-
-* When calling `update_columns` on a record that is not persisted, the error
- message now reflects whether that object is a new record or has been
- destroyed.
-
- *Lachlan Sylvester*
-
-* Define `id_was` to get the previous value of the primary key.
-
- Currently when we call `id_was` and we have a custom primary key name,
- Active Record will return the current value of the primary key. This
- makes it impossible to correctly do an update operation if you change the
- id.
-
- Fixes #16413.
-
- *Rafael Mendonça França*
-
-* Deprecate `DatabaseTasks.load_schema` to act on the current connection.
- Use `.load_schema_current` instead. In the future `load_schema` will
- require the `configuration` to act on as an argument.
-
- *Yves Senn*
-
-* Fix automatic maintaining test schema to properly handle sql structure
- schema format.
-
- Fixes #15394.
-
- *Wojciech Wnętrzak*
-
-* Fix type casting to Decimal from Float with large precision.
-
- *Tomohiro Hashidate*
-
-* Deprecate `Reflection#source_macro`
-
- `Reflection#source_macro` is no longer needed in Active Record
- source so it has been deprecated. Code that used `source_macro`
- was removed in #16353.
-
- *Eileen M. Uchtitelle*, *Aaron Patterson*
-
-* No verbose backtrace by `db:drop` when database does not exist.
-
- Fixes #16295.
-
- *Kenn Ejima*
-
-* Add support for PostgreSQL JSONB.
-
- Example:
-
- create_table :posts do |t|
- t.jsonb :meta_data
- end
-
- *Philippe Creux*, *Chris Teague*
-
-* `db:purge` with MySQL respects `Rails.env`.
-
- *Yves Senn*
-
-* `change_column_default :table, :column, nil` with PostgreSQL will issue a
- `DROP DEFAULT` instead of a `DEFAULT NULL` query.
-
- Fixes #16261.
-
- *Matthew Draper*, *Yves Senn*
-
-* Allow to specify a type for the foreign key column in `references`
- and `add_reference`.
-
- Example:
-
- change_table :vehicle do |t|
- t.references :station, type: :uuid
- end
-
- *Andrey Novikov*, *Łukasz Sarnacki*
-
-* `create_join_table` removes a common prefix when generating the join table.
- This matches the existing behavior of HABTM associations.
-
- Fixes #13683.
-
- *Stefan Kanev*
-
-* Do not swallow errors on `compute_type` when having a bad `alias_method` on
- a class.
-
- *arthurnn*
-
-* PostgreSQL invalid `uuid` are convert to nil.
-
- *Abdelkader Boudih*
-
-* Restore 4.0 behavior for using serialize attributes with `JSON` as coder.
-
- With 4.1.x, `serialize` started returning a string when `JSON` was passed as
- the second attribute. It will now return a hash as per previous versions.
-
- Example:
-
- class Post < ActiveRecord::Base
- serialize :comment, JSON
- end
-
- class Comment
- include ActiveModel::Model
- attr_accessor :category, :text
- end
-
- post = Post.create!
- post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.")
- post.save!
-
- # 4.0
- post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
-
- # 4.1 before
- post.comment # => "#<Comment:0x007f80ab48ff98>"
-
- # 4.1 after
- post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
-
- When using `JSON` as the coder in `serialize`, Active Record will use the
- new `ActiveRecord::Coders::JSON` coder which delegates its `dump/load` to
- `ActiveSupport::JSON.encode/decode`. This ensures special objects are dumped
- correctly using the `#as_json` hook.
-
- To keep the previous behaviour, supply a custom coder instead
- ([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)).
-
- Fixes #15594.
-
- *Jenn Cooper*
-
-* Do not use `RENAME INDEX` syntax for MariaDB 10.0.
-
- Fixes #15931.
-
- *Jeff Browning*
-
-* Calling `#empty?` on a `has_many` association would use the value from the
- counter cache if one exists.
-
- *David Verhasselt*
-
-* Fix the schema dump generated for tables without constraints and with
- primary key with default value of custom PostgreSQL function result.
-
- Fixes #16111.
-
- *Andrey Novikov*
-
-* Fix the SQL generated when a `delete_all` is run on an association to not
- produce an `IN` statements.
-
- Before:
-
- UPDATE "categorizations" SET "category_id" = NULL WHERE
- "categorizations"."category_id" = 1 AND "categorizations"."id" IN (1, 2)
-
- After:
-
- UPDATE "categorizations" SET "category_id" = NULL WHERE
- "categorizations"."category_id" = 1
-
- *Eileen M. Uchitelle, Aaron Patterson*
-
-* Avoid type casting boolean and `ActiveSupport::Duration` values to numeric
- values for string columns. Otherwise, in some database, the string column
- values will be coerced to a numeric allowing false or 0.seconds match any
- string starting with a non-digit.
-
- Example:
-
- App.where(apikey: false) # => SELECT * FROM users WHERE apikey = '0'
-
- *Dylan Thacker-Smith*
-
-* Add a `:required` option to singular associations, providing a nicer
- API for presence validations on associations.
-
- *Sean Griffin*
-
-* Fix an error in `reset_counters` when associations have `select` scope.
- (Call to `count` generated invalid SQL.)
-
- *Cade Truitt*
-
-* After a successful `reload`, `new_record?` is always false.
-
- Fixes #12101.
-
- *Matthew Draper*
-
-* PostgreSQL renaming table doesn't attempt to rename non existent sequences.
-
- *Abdelkader Boudih*
-
-* Move 'dependent: :destroy' handling for `belongs_to`
- from `before_destroy` to `after_destroy` callback chain
-
- Fixes #12380.
-
- *Ivan Antropov*
-
-* Detect in-place modifications on String attributes.
-
- Before this change, an attribute modified in-place had to be marked as
- changed in order for it to be persisted in the database. Now it is no longer
- required.
-
- Before:
-
- user = User.first
- user.name << ' Griffin'
- user.name_will_change!
- user.save
- user.reload.name # => "Sean Griffin"
-
- After:
-
- user = User.first
- user.name << ' Griffin'
- user.save
- user.reload.name # => "Sean Griffin"
-
- *Sean Griffin*
-
-* Add `ActiveRecord::Base#validate!` that raises `RecordInvalid` if the record
- is invalid.
-
- *Bogdan Gusiev*, *Marc Schütz*
-
-* Support for adding and removing foreign keys. Foreign keys are now
- a part of `schema.rb`. This is supported by Mysql2Adapter, MysqlAdapter
- and PostgreSQLAdapter.
-
- Many thanks to *Matthew Higgins* for laying the foundation with his work on
- [foreigner](https://github.com/matthuhiggins/foreigner).
-
- Example:
-
- # within your migrations:
- add_foreign_key :articles, :authors
- remove_foreign_key :articles, :authors
-
- *Yves Senn*
-
-* Fix subtle bugs regarding attribute assignment on models with no primary
- key. `'id'` will no longer be part of the attributes hash.
-
- *Sean Griffin*
-
-* Deprecate automatic counter caches on `has_many :through`. The behavior was
- broken and inconsistent.
-
- *Sean Griffin*
-
-* `preload` preserves readonly flag for associations.
-
- See #15853.
-
- *Yves Senn*
-
-* Assume numeric types have changed if they were assigned to a value that
- would fail numericality validation, regardless of the old value. Previously
- this would only occur if the old value was 0.
-
- Example:
-
- model = Model.create!(number: 5)
- model.number = '5wibble'
- model.number_changed? # => true
-
- Fixes #14731.
-
- *Sean Griffin*
-
-* `reload` no longer merges with the existing attributes.
- The attribute hash is fully replaced. The record is put into the same state
- as it would be with `Model.find(model.id)`.
-
- *Sean Griffin*
-
-* The object returned from `select_all` must respond to `column_types`.
- If this is not the case a `NoMethodError` is raised.
-
- *Sean Griffin*
-
-* Detect in-place modifications of PG array types
-
- *Sean Griffin*
-
-* Add `bin/rake db:purge` task to empty the current database.
-
- *Yves Senn*
-
-* Deprecate `serialized_attributes` without replacement.
-
- *Sean Griffin*
-
-* Correctly extract IPv6 addresses from `DATABASE_URI`: the square brackets
- are part of the URI structure, not the actual host.
-
- Fixes #15705.
-
- *Andy Bakun*, *Aaron Stone*
-
-* Ensure both parent IDs are set on join records when both sides of a
- through association are new.
-
- *Sean Griffin*
-
-* `ActiveRecord::Dirty` now detects in-place changes to mutable values.
- Serialized attributes on ActiveRecord models will no longer save when
- unchanged.
-
- Fixes #8328.
-
- *Sean Griffin*
-
-* `Pluck` now works when selecting columns from different tables with the same
- name.
-
- Fixes #15649.
-
- *Sean Griffin*
-
-* Remove `cache_attributes` and friends. All attributes are cached.
-
- *Sean Griffin*
-
-* Remove deprecated method `ActiveRecord::Base.quoted_locking_column`.
-
- *Akshay Vishnoi*
-
-* `ActiveRecord::FinderMethods.find` with block can handle proc parameter as
- `Enumerable#find` does.
-
- Fixes #15382.
-
- *James Yang*
-
-* Make timezone aware attributes work with PostgreSQL array columns.
-
- Fixes #13402.
-
- *Kuldeep Aggarwal*, *Sean Griffin*
-
-* `ActiveRecord::SchemaMigration` has no primary key regardless of the
- `primary_key_prefix_type` configuration.
-
- Fixes #15051.
-
- *JoseLuis Torres*, *Yves Senn*
-
-* `rake db:migrate:status` works with legacy migration numbers like `00018_xyz.rb`.
-
- Fixes #15538.
-
- *Yves Senn*
-
-* Baseclass becomes! subclass.
-
- Before this change, a record which changed its STI type, could not be
- updated.
-
- Fixes #14785.
-
- *Matthew Draper*, *Earl St Sauver*, *Edo Balvers*
-
-* Remove deprecated `ActiveRecord::Migrator.proper_table_name`. Use the
- `proper_table_name` instance method on `ActiveRecord::Migration` instead.
-
- *Akshay Vishnoi*
-
-* Fix regression on eager loading association based on SQL query rather than
- existing column.
-
- Fixes #15480.
-
- *Lauro Caetano*, *Carlos Antonio da Silva*
-
-* Deprecate returning `nil` from `column_for_attribute` when no column exists.
- It will return a null object in Rails 5.0
-
- *Sean Griffin*
-
-* Implemented `ActiveRecord::Base#pretty_print` to work with PP.
-
- *Ethan*
-
-* Preserve type when dumping PostgreSQL point, bit, bit varying and money
- columns.
-
- *Yves Senn*
-
-* New records remain new after YAML serialization.
-
- *Sean Griffin*
-
-* PostgreSQL support default values for enum types. Fixes #7814.
-
- *Yves Senn*
-
-* PostgreSQL `default_sequence_name` respects schema. Fixes #7516.
-
- *Yves Senn*
-
-* Fix `columns_for_distinct` of PostgreSQL adapter to work correctly
- with orders without sort direction modifiers.
-
- *Nikolay Kondratyev*
-
-* PostgreSQL `reset_pk_sequence!` respects schemas. Fixes #14719.
-
- *Yves Senn*
-
-* Keep PostgreSQL `hstore` and `json` attributes as `Hash` in `@attributes`.
- Fixes duplication in combination with `store_accessor`.
-
- Fixes #15369.
-
- *Yves Senn*
-
-* `rake railties:install:migrations` respects the order of railties.
-
- *Arun Agrawal*
-
-* Fix redefine a `has_and_belongs_to_many` inside inherited class
- Fixing regression case, where redefining the same `has_and_belongs_to_many`
- definition into a subclass would raise.
-
- Fixes #14983.
-
- *arthurnn*
-
-* Fix `has_and_belongs_to_many` public reflection.
- When defining a `has_and_belongs_to_many`, internally we convert that to two has_many.
- But as `reflections` is a public API, people expect to see the right macro.
-
- Fixes #14682.
-
- *arthurnn*
-
-* Fix serialization for records with an attribute named `format`.
-
- Fixes #15188.
-
- *Godfrey Chan*
-
-* When a `group` is set, `sum`, `size`, `average`, `minimum` and `maximum`
- on a NullRelation should return a Hash.
-
- *Kuldeep Aggarwal*
-
-* Fix serialized fields returning serialized data after being updated with
- `update_column`.
-
- *Simon Hørup Eskildsen*
-
-* Fix polymorphic eager loading when using a String as foreign key.
-
- Fixes #14734.
-
- *Lauro Caetano*
-
-* Change belongs_to touch to be consistent with timestamp updates
-
- If a model is set up with a belongs_to: touch relationship the parent
- record will only be touched if the record was modified. This makes it
- consistent with timestamp updating on the record itself.
-
- *Brock Trappitt*
-
-* Fix the inferred table name of a `has_and_belongs_to_many` auxiliary
- table inside a schema.
-
- Fixes #14824.
-
- *Eric Chahin*
-
-* Remove unused `:timestamp` type. Transparently alias it to `:datetime`
- in all cases. Fixes inconsistencies when column types are sent outside of
- `ActiveRecord`, such as for XML Serialization.
-
- *Sean Griffin*
-
-* Fix bug that added `table_name_prefix` and `table_name_suffix` to
- extension names in PostgreSQL when migrating.
-
- *Joao Carlos*
-
-* The `:index` option in migrations, which previously was only available for
- `references`, now works with any column types.
-
- *Marc Schütz*
-
-* Add support for counter name to be passed as parameter on `CounterCache::ClassMethods#reset_counters`.
-
- *jnormore*
-
-* Restrict deletion of record when using `delete_all` with `uniq`, `group`, `having`
- or `offset`.
-
- In these cases the generated query ignored them and that caused unintended
- records to be deleted.
-
- Fixes #11985.
-
- *Leandro Facchinetti*
-
-* Floats with limit >= 25 that get turned into doubles in MySQL no longer have
- their limit dropped from the schema.
-
- Fixes #14135.
-
- *Aaron Nelson*
-
-* Fix how to calculate associated class name when using namespaced `has_and_belongs_to_many`
- association.
-
- Fixes #14709.
-
- *Kassio Borges*
-
-* `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and
- strings in column names as equal.
-
- This fixes a rare case in which more bind values are passed than there are
- placeholders for them in the generated SQL statement, which can make PostgreSQL
- throw a `StatementInvalid` exception.
-
- *Nat Budin*
-
-* Fix `stored_attributes` to correctly merge the details of stored
- attributes defined in parent classes.
-
- Fixes #14672.
-
- *Brad Bennett*, *Jessica Yao*, *Lakshmi Parthasarathy*
-
-* `change_column_default` allows `[]` as argument to `change_column_default`.
-
- Fixes #11586.
-
- *Yves Senn*
-
-* Handle `name` and `"char"` column types in the PostgreSQL adapter.
-
- `name` and `"char"` are special character types used internally by
- PostgreSQL and are used by internal system catalogs. These field types
- can sometimes show up in structure-sniffing queries that feature internal system
- structures or with certain PostgreSQL extensions.
-
- *J Smith*, *Yves Senn*
-
-* Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and
- NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
-
- Before:
-
- Point.create(value: 1.0/0)
- Point.last.value # => 0.0
-
- After:
-
- Point.create(value: 1.0/0)
- Point.last.value # => Infinity
-
- *Innokenty Mikhailov*
-
-* Allow the PostgreSQL adapter to handle bigserial primary key types again.
-
- Fixes #10410.
-
- *Patrick Robertson*
-
-* Deprecate joining, eager loading and preloading of instance dependent
- associations without replacement. These operations happen before instances
- are created. The current behavior is unexpected and can result in broken
- behavior.
-
- Fixes #15024.
-
- *Yves Senn*
-
-* Fix `has_and_belongs_to_many` CollectionAssociation size calculations.
-
- `has_and_belongs_to_many` should fall back to using the normal CollectionAssociation's
- size calculation if the collection is not cached or loaded.
-
- Fixes #14913, #14914.
-
- *Fred Wu*
-
-* Return a non zero status when running `rake db:migrate:status` and migration table does
- not exist.
-
- *Paul B.*
-
-* Add support for module-level `table_name_suffix` in models.
-
- This makes `table_name_suffix` work the same way as `table_name_prefix` when
- using namespaced models.
-
- *Jenner LaFave*
-
-* Revert the behaviour of `ActiveRecord::Relation#join` changed through 4.0 => 4.1 to 4.0.
-
- In 4.1.0 `Relation#join` is delegated to `Arel#SelectManager`.
- In 4.0 series it is delegated to `Array#join`.
-
- *Bogdan Gusiev*
-
-* Log nil binary column values correctly.
-
- When an object with a binary column is updated with a nil value
- in that column, the SQL logger would throw an exception when trying
- to log that nil value. This only occurs when updating a record
- that already has a non-nil value in that column since an initial nil
- value isn't included in the SQL anyway (at least, when dirty checking
- is enabled.) The column's new value will now be logged as `<NULL binary data>`
- to parallel the existing `<N bytes of binary data>` for non-nil values.
-
- *James Coleman*
-
-* Rails will now pass a custom validation context through to autosave associations
- in order to validate child associations with the same context.
-
- Fixes #13854.
-
- *Eric Chahin*, *Aaron Nelson*, *Kevin Casey*
-
-* Stringify all variables keys of MySQL connection configuration.
-
- When `sql_mode` variable for MySQL adapters set in configuration as `String`
- was ignored and overwritten by strict mode option.
-
- Fixes #14895.
-
- *Paul Nikitochkin*
-
-* Ensure SQLite3 statements are closed on errors.
-
- Fixes #13631.
-
- *Timur Alperovich*
-
-* Give `ActiveRecord::PredicateBuilder` private methods the privacy they deserve.
-
- *Hector Satre*
-
-* When using a custom `join_table` name on a `habtm`, rails was not saving it
- on Reflections. This causes a problem when rails loads fixtures, because it
- uses the reflections to set database with fixtures.
-
- Fixes #14845.
-
- *Kassio Borges*
-
-* Reset the cache when modifying a Relation with cached Arel.
- Additionally display a warning message to make the user aware.
-
- *Yves Senn*
-
-* PostgreSQL should internally use `:datetime` consistently for TimeStamp. Assures
- different spellings of timestamps are treated the same.
-
- Example:
-
- mytimestamp.simplified_type('timestamp without time zone')
- # => :datetime
- mytimestamp.simplified_type('timestamp(6) without time zone')
- # => also :datetime (previously would be :timestamp)
-
- See #14513.
-
- *Jefferson Lai*
-
-* `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
-
- Fixes #14841.
-
- *Lucas Mazza*
-
-* Fix name collision with `Array#select!` with `Relation#select!`.
-
- Fixes #14752.
-
- *Earl St Sauver*
-
-* Fix unexpected behavior for `has_many :through` associations going through
- a scoped `has_many`.
-
- If a `has_many` association is adjusted using a scope, and another
- `has_many :through` uses this association, then the scope adjustment is
- unexpectedly neglected.
-
- Fixes #14537.
-
- *Jan Habermann*
-
-* `@destroyed` should always be set to `false` when an object is duped.
-
- *Kuldeep Aggarwal*
-
-* Enable `has_many` associations to support irregular inflections.
-
- Fixes #8928.
-
- *arthurnn*, *Javier Goizueta*
-
-* Fix `count` used with a grouping not returning a Hash.
-
- Fixes #14721.
-
- *Eric Chahin*
-
-* `sanitize_sql_like` helper method to escape a string for safe use in an SQL
- LIKE statement.
-
- Example:
-
- class Article
- def self.search(term)
- where("title LIKE ?", sanitize_sql_like(term))
- end
- end
-
- Article.search("20% _reduction_")
- # => Query looks like "... title LIKE '20\% \_reduction\_' ..."
-
- *Rob Gilson*, *Yves Senn*
-
-* Do not quote uuid default value on `change_column`.
-
- Fixes #14604.
-
- *Eric Chahin*
-
-* The comparison between `Relation` and `CollectionProxy` should be consistent.
-
- Example:
-
- author.posts == Post.where(author_id: author.id)
- # => true
- Post.where(author_id: author.id) == author.posts
- # => true
-
- Fixes #13506.
-
- *Lauro Caetano*
-
-* Calling `delete_all` on an unloaded `CollectionProxy` no longer
- generates an SQL statement containing each id of the collection:
-
- Before:
-
- DELETE FROM `model` WHERE `model`.`parent_id` = 1
- AND `model`.`id` IN (1, 2, 3...)
-
- After:
-
- DELETE FROM `model` WHERE `model`.`parent_id` = 1
-
- *Eileen M. Uchitelle*, *Aaron Patterson*
-
-* Fix invalid SQL when aggregate methods (`empty?`, `any?`, `count`) used
- with `select`.
-
- Fixes #13648.
-
- *Simon Woker*
-
-* PostgreSQL adapter only warns once for every missing OID per connection.
-
- Fixes #14275.
-
- *Matthew Draper*, *Yves Senn*
-
-* PostgreSQL adapter automatically reloads it's type map when encountering
- unknown OIDs.
-
- Fixes #14678.
-
- *Matthew Draper*, *Yves Senn*
-
-* Fix insertion of records via `has_many :through` association with scope.
-
- Fixes #3548.
-
- *Ivan Antropov*
-
-* Auto-generate stable fixture UUIDs on PostgreSQL.
-
- Fixes #11524.
-
- *Roderick van Domburg*
-
-* Fix a problem where an enum would overwrite values of another enum with the
- same name in an unrelated class.
-
- Fixes #14607.
-
- *Evan Whalen*
-
-* PostgreSQL and SQLite string columns no longer have a default limit of 255.
-
- Fixes #13435, #9153.
-
- *Vladimir Sazhin*, *Toms Mikoss*, *Yves Senn*
-
-* Make possible to have an association called `records`.
-
- Fixes #11645.
-
- *prathamesh-sonpatki*
-
-* `to_sql` on an association now matches the query that is actually executed, where it
- could previously have incorrectly accrued additional conditions (e.g. as a result of
- a previous query). `CollectionProxy` now always defers to the association scope's
- `arel` method so the (incorrect) inherited one should be entirely concealed.
-
- Fixes #14003.
-
- *Jefferson Lai*
-
-* Block a few default Class methods as scope name.
-
- For instance, this will raise:
-
- scope :public, -> { where(status: 1) }
-
- *arthurnn*
-
-* Fix error when using `with_options` with lambda.
-
- Fixes #9805.
-
- *Lauro Caetano*
-
-* Switch `sqlite3:///` URLs (which were temporarily
- deprecated in 4.1) from relative to absolute.
-
- If you still want the previous interpretation, you should replace
- `sqlite3:///my/path` with `sqlite3:my/path`.
-
- *Matthew Draper*
-
-* Treat blank UUID values as `nil`.
-
- Example:
-
- Sample.new(uuid_field: '') #=> <Sample id: nil, uuid_field: nil>
-
- *Dmitry Lavrov*
-
-* Enable support for materialized views on PostgreSQL >= 9.3.
-
- *Dave Lee*
-
-* The PostgreSQL adapter supports custom domains. Fixes #14305.
-
- *Yves Senn*
-
-* PostgreSQL `Column#type` is now determined through the corresponding OID.
- The column types stay the same except for enum columns. They no longer have
- `nil` as type but `enum`.
-
- See #7814.
-
- *Yves Senn*
-
-* Fix error when specifying a non-empty default value on a PostgreSQL array
- column.
-
- Fixes #10613.
-
- *Luke Steensen*
-
-* Fix error where `.persisted?` throws SystemStackError for an unsaved model with a
- custom primary key that did not save due to validation error.
-
- Fixes #14393.
-
- *Chris Finne*
-
-* Introduce `validate` as an alias for `valid?`.
-
- This is more intuitive when you want to run validations but don't care about the return value.
-
- *Henrik Nyh*
-
-* Create indexes inline in CREATE TABLE for MySQL.
-
- This is important, because adding an index on a temporary table after it has been created
- would commit the transaction.
-
- It also allows creating and dropping indexed tables with fewer queries and fewer permissions
- required.
-
- Example:
-
- create_table :temp, temporary: true, as: "SELECT id, name, zip FROM a_really_complicated_query" do |t|
- t.index :zip
- end
- # => CREATE TEMPORARY TABLE temp (INDEX (zip)) AS SELECT id, name, zip FROM a_really_complicated_query
-
- *Cody Cutrer*, *Steve Rice*, *Rafael Mendonça Franca*
-
-* Use singular table name in generated migrations when
- `ActiveRecord::Base.pluralize_table_names` is `false`.
-
- Fixes #13426.
-
- *Kuldeep Aggarwal*
-
-* `touch` accepts many attributes to be touched at once.
-
- Example:
-
- # touches :signed_at, :sealed_at, and :updated_at/on attributes.
- Photo.last.touch(:signed_at, :sealed_at)
-
- *James Pinto*
-
-* `rake db:structure:dump` only dumps schema information if the schema
- migration table exists.
-
- Fixes #14217.
-
- *Yves Senn*
-
-* Reap connections that were checked out by now-dead threads, instead
- of waiting until they disconnect by themselves. Before this change,
- a suitably constructed series of short-lived threads could starve
- the connection pool, without ever having more than a couple alive at
- the same time.
-
- *Matthew Draper*
-
-* `pk_and_sequence_for` now ensures that only the pg_depend entries
- pointing to pg_class, and thus only sequence objects, are considered.
-
- *Josh Williams*
-
-* `where.not` adds `references` for `includes` like normal `where` calls do.
-
- Fixes #14406.
-
- *Yves Senn*
-
-* Extend fixture `$LABEL` replacement to allow string interpolation.
-
- Example:
-
- martin:
- email: $LABEL@email.com
-
- users(:martin).email # => martin@email.com
-
- *Eric Steele*
-
-* Add support for `Relation` be passed as parameter on `QueryCache#select_all`.
-
- Fixes #14361.
-
- *arthurnn*
-
-* Passing an Active Record object to `find` or `exists?` is now deprecated.
- Call `.id` on the object first.
-
- *Aaron Patterson*
-
-* Only use BINARY for MySQL case sensitive uniqueness check when column
- has a case insensitive collation.
-
- *Ryuta Kamizono*
-
-* Support for MySQL 5.6 fractional seconds.
-
- *arthurnn*, *Tatsuhiko Miyagawa*
-
-* Support for PostgreSQL `citext` data type enabling case-insensitive
- `where` values without needing to wrap in UPPER/LOWER sql functions.
-
- *Troy Kruthoff*, *Lachlan Sylvester*
-
-* Only save has_one associations if record has changes.
- Previously after save related callbacks, such as `#after_commit`, were triggered when the has_one
- object did not get saved to the db.
-
- *Alan Kennedy*
-
-* Allow strings to specify the `#order` value.
-
- Example:
-
- Model.order(id: 'asc').to_sql == Model.order(id: :asc).to_sql
-
- *Marcelo Casiraghi*, *Robin Dupret*
-
-* Dynamically register PostgreSQL enum OIDs. This prevents "unknown OID"
- warnings on enum columns.
-
- *Dieter Komendera*
-
-* `includes` is able to detect the right preloading strategy when string
- joins are involved.
-
- Fixes #14109.
-
- *Aaron Patterson*, *Yves Senn*
-
-* Fix error with validation with enum fields for records where the value for
- any enum attribute is always evaluated as 0 during uniqueness validation.
-
- Fixes #14172.
-
- *Vilius Luneckas* *Ahmed AbouElhamayed*
-
-* `before_add` callbacks are fired before the record is saved on
- `has_and_belongs_to_many` associations *and* on `has_many :through`
- associations. Before this change, `before_add` callbacks would be fired
- before the record was saved on `has_and_belongs_to_many` associations, but
- *not* on `has_many :through` associations.
-
- Fixes #14144.
-
-* Fix STI classes not defining an attribute method if there is a conflicting
- private method defined on its ancestors.
-
- Fixes #11569.
-
- *Godfrey Chan*
-
-* Coerce strings when reading attributes. Fixes #10485.
-
- Example:
-
- book = Book.new(title: 12345)
- book.save!
- book.title # => "12345"
-
- *Yves Senn*
-
-* Deprecate half-baked support for PostgreSQL range values with excluding beginnings.
- We currently map PostgreSQL ranges to Ruby ranges. This conversion is not fully
- possible because the Ruby range does not support excluded beginnings.
-
- The current solution of incrementing the beginning is not correct and is now
- deprecated. For subtypes where we don't know how to increment (e.g. `#succ`
- is not defined) it will raise an `ArgumentException` for ranges with excluding
- beginnings.
-
- *Yves Senn*
-
-* Support for user created range types in PostgreSQL.
-
- *Yves Senn*
-
-Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activerecord/CHANGELOG.md) for previous changes.
+Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activerecord/CHANGELOG.md) for previous changes.
diff --git a/activerecord/activerecord.gemspec b/activerecord/activerecord.gemspec
index 834fffeb18..471769a962 100644
--- a/activerecord/activerecord.gemspec
+++ b/activerecord/activerecord.gemspec
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.summary = 'Object-relational mapper framework (part of Rails).'
s.description = 'Databases on Rails. Build a persistent domain model by mapping database tables to Ruby classes. Strong conventions for associations, validations, aggregations, migrations, and testing come baked-in.'
- s.required_ruby_version = '>= 1.9.3'
+ s.required_ruby_version = '>= 2.1.0'
s.license = 'MIT'
diff --git a/activerecord/examples/performance.rb b/activerecord/examples/performance.rb
index d3546ce948..a5a1f284a0 100644
--- a/activerecord/examples/performance.rb
+++ b/activerecord/examples/performance.rb
@@ -39,8 +39,8 @@ class Exhibit < ActiveRecord::Base
where("notes IS NOT NULL")
end
- def self.look(exhibits) exhibits.each { |e| e.look } end
- def self.feel(exhibits) exhibits.each { |e| e.feel } end
+ def self.look(exhibits) exhibits.each(&:look) end
+ def self.feel(exhibits) exhibits.each(&:feel) end
end
def progress_bar(int); print "." if (int%100).zero? ; end
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index d2bcdc55bf..eb21712f96 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -57,7 +57,7 @@ module ActiveRecord
through_reflection = reflection.through_reflection
source_reflection_names = reflection.source_reflection_names
source_associations = reflection.through_reflection.klass._reflections.keys
- super("Could not find the source association(s) #{source_reflection_names.collect{ |a| a.inspect }.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)} in model #{through_reflection.klass}. Try 'has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}, :source => <name>'. Is it one of #{source_associations.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)}?")
+ super("Could not find the source association(s) #{source_reflection_names.collect(&:inspect).to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)} in model #{through_reflection.klass}. Try 'has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}, :source => <name>'. Is it one of #{source_associations.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)}?")
end
end
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 2b7d39893d..7b6aefe345 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -62,9 +62,9 @@ module ActiveRecord
# Implements the ids writer method, e.g. foo.item_ids= for Foo.has_many :items
def ids_writer(ids)
pk_type = reflection.primary_key_type
- ids = Array(ids).reject { |id| id.blank? }
+ ids = Array(ids).reject(&:blank?)
ids.map! { |i| pk_type.type_cast_from_user(i) }
- replace(klass.find(ids).index_by { |r| r.id }.values_at(*ids))
+ replace(klass.find(ids).index_by(&:id).values_at(*ids))
end
def reset
@@ -289,7 +289,7 @@ module ActiveRecord
elsif !loaded? && !association_scope.group_values.empty?
load_target.size
elsif !loaded? && !association_scope.distinct_value && target.is_a?(Array)
- unsaved_records = target.select { |r| r.new_record? }
+ unsaved_records = target.select(&:new_record?)
unsaved_records.size + count_records
else
count_records
@@ -506,7 +506,7 @@ module ActiveRecord
def delete_or_destroy(records, method)
records = records.flatten
records.each { |record| raise_on_type_mismatch!(record) }
- existing_records = records.reject { |r| r.new_record? }
+ existing_records = records.reject(&:new_record?)
if existing_records.empty?
remove_records(existing_records, records, method)
@@ -609,7 +609,7 @@ module ActiveRecord
# specified, then #find scans the entire collection.
def find_by_scan(*args)
expects_array = args.first.kind_of?(Array)
- ids = args.flatten.compact.map{ |arg| arg.to_s }.uniq
+ ids = args.flatten.compact.map(&:to_s).uniq
if ids.size == 1
id = ids.first
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb
index 6329fdfe95..5cfedcc009 100644
--- a/activerecord/lib/active_record/associations/has_many_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -161,9 +161,7 @@ module ActiveRecord
if scope.klass.primary_key
count = scope.destroy_all.length
else
- scope.each do |record|
- record._run_destroy_callbacks
- end
+ scope.each(&:_run_destroy_callbacks)
arel = scope.arel
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb
index 285d0ec9af..cf63430a97 100644
--- a/activerecord/lib/active_record/associations/join_dependency.rb
+++ b/activerecord/lib/active_record/associations/join_dependency.rb
@@ -20,7 +20,7 @@ module ActiveRecord
end
def columns
- @tables.flat_map { |t| t.column_aliases }
+ @tables.flat_map(&:column_aliases)
end
# An array of [column_name, alias] pairs for the table
diff --git a/activerecord/lib/active_record/associations/preloader/has_many_through.rb b/activerecord/lib/active_record/associations/preloader/has_many_through.rb
index 7b37b5942d..2029871f39 100644
--- a/activerecord/lib/active_record/associations/preloader/has_many_through.rb
+++ b/activerecord/lib/active_record/associations/preloader/has_many_through.rb
@@ -8,7 +8,7 @@ module ActiveRecord
records_by_owner = super
if reflection_scope.distinct_value
- records_by_owner.each_value { |records| records.uniq! }
+ records_by_owner.each_value(&:uniq!)
end
records_by_owner
diff --git a/activerecord/lib/active_record/attribute_assignment.rb b/activerecord/lib/active_record/attribute_assignment.rb
index 2887db3bf7..bf64830417 100644
--- a/activerecord/lib/active_record/attribute_assignment.rb
+++ b/activerecord/lib/active_record/attribute_assignment.rb
@@ -87,7 +87,7 @@ module ActiveRecord
end
end
unless errors.empty?
- error_descriptions = errors.map { |ex| ex.message }.join(",")
+ error_descriptions = errors.map(&:message).join(",")
raise MultiparameterAssignmentErrors.new(errors), "#{errors.size} error(s) on assignment of multiparameter attributes [#{error_descriptions}]"
end
end
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index a0d70435fa..c39b045a5e 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -263,9 +263,9 @@ module ActiveRecord
if new_record
association && association.target
elsif autosave
- association.target.find_all { |record| record.changed_for_autosave? }
+ association.target.find_all(&:changed_for_autosave?)
else
- association.target.find_all { |record| record.new_record? }
+ association.target.find_all(&:new_record?)
end
end
@@ -275,7 +275,7 @@ module ActiveRecord
self.class._reflections.values.any? do |reflection|
if reflection.options[:autosave]
association = association_instance_get(reflection.name)
- association && Array.wrap(association.target).any? { |a| a.changed_for_autosave? }
+ association && Array.wrap(association.target).any?(&:changed_for_autosave?)
end
end
end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index 46812b75bb..3a9db4a109 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -320,9 +320,7 @@ module ActiveRecord
checkin conn
conn.disconnect! if conn.requires_reloading?
end
- @connections.delete_if do |conn|
- conn.requires_reloading?
- end
+ @connections.delete_if(&:requires_reloading?)
@available.clear
@connections.each do |conn|
@available.add conn
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb
index 792d49da6f..5c95b95184 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb
@@ -81,7 +81,7 @@ module ActiveRecord
end
def add_column_options!(sql, options)
- sql << " DEFAULT #{quote_value(options[:default], options[:column])}" if options_include_default?(options)
+ sql << " DEFAULT #{quote_default_expression(options[:default], options[:column])}" if options_include_default?(options)
# must explicitly check for :null to allow change_column to work on migrations
if options[:null] == false
sql << " NOT NULL"
@@ -92,7 +92,7 @@ module ActiveRecord
sql
end
- def quote_value(value, column)
+ def quote_default_expression(value, column)
column.sql_type ||= type_to_sql(column.type, column.limit, column.precision, column.scale)
column.cast_type ||= type_for_column(column)
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index 99fa9b7d29..aa7c406050 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -781,7 +781,7 @@ module ActiveRecord
version = version.to_i
sm_table = quote_table_name(ActiveRecord::Migrator.schema_migrations_table_name)
- migrated = select_values("SELECT version FROM #{sm_table}").map { |v| v.to_i }
+ migrated = select_values("SELECT version FROM #{sm_table}").map(&:to_i)
paths = migrations_paths.map {|p| "#{p}/[0-9]*_*.rb" }
versions = Dir[*paths].map do |filename|
filename.split('/').last.split('_').first.to_i
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
index c824a7b11b..bf16804aa0 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -398,7 +398,7 @@ module ActiveRecord
sql << "LIKE #{quote(like)}" if like
execute_and_free(sql, 'SCHEMA') do |result|
- result.collect { |field| field.first }
+ result.collect(&:first)
end
end
@@ -786,7 +786,7 @@ module ActiveRecord
private
def version
- @version ||= full_version.scan(/^(\d+)\.(\d+)\.(\d+)/).flatten.map { |v| v.to_i }
+ @version ||= full_version.scan(/^(\d+)\.(\d+)\.(\d+)/).flatten.map(&:to_i)
end
def mariadb?
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
index 53ad71b445..23d8389abb 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -423,9 +423,7 @@ module ActiveRecord
cols = nil
if metadata = stmt.result_metadata
- cols = cache[:cols] ||= metadata.fetch_fields.map { |field|
- field.name
- }
+ cols = cache[:cols] ||= metadata.fetch_fields.map(&:name)
metadata.free
end
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
index dba905ed56..f29b793a3f 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -13,14 +13,22 @@ module ActiveRecord
sql
end
+ def column_options(o)
+ column_options = super
+ column_options[:array] = o.array
+ column_options
+ end
+
def add_column_options!(sql, options)
- if options[:array] || options[:column].try(:array)
+ if options[:array]
sql << '[]'
end
+ super
+ end
- column = options.fetch(:column) { return super }
- if column.type == :uuid && options[:default] =~ /\(\)/
- sql << " DEFAULT #{options[:default]}"
+ def quote_default_expression(value, column)
+ if column.type == :uuid && value =~ /\(\)/
+ value
else
super
end
diff --git a/activerecord/lib/active_record/connection_adapters/schema_cache.rb b/activerecord/lib/active_record/connection_adapters/schema_cache.rb
index a10ce330c7..37ff4e4613 100644
--- a/activerecord/lib/active_record/connection_adapters/schema_cache.rb
+++ b/activerecord/lib/active_record/connection_adapters/schema_cache.rb
@@ -61,9 +61,7 @@ module ActiveRecord
end
def size
- [@columns, @columns_hash, @primary_keys, @tables].map { |x|
- x.size
- }.inject :+
+ [@columns, @columns_hash, @primary_keys, @tables].map(&:size).inject :+
end
# Clear out internal caches for table with +table_name+.
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
index 0b8b6a2bf8..c3865a8fdd 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
@@ -88,11 +88,11 @@ module ActiveRecord
include Comparable
def initialize(version_string)
- @version = version_string.split('.').map { |v| v.to_i }
+ @version = version_string.split('.').map(&:to_i)
end
def <=>(version_string)
- @version <=> version_string.split('.').map { |v| v.to_i }
+ @version <=> version_string.split('.').map(&:to_i)
end
end
@@ -556,7 +556,7 @@ module ActiveRecord
end
copy_table_indexes(from, to, options[:rename] || {})
copy_table_contents(from, to,
- @definition.columns.map {|column| column.name},
+ @definition.columns.map(&:name),
options[:rename] || {})
end
@@ -569,7 +569,7 @@ module ActiveRecord
name = name[1..-1]
end
- to_column_names = columns(to).map { |c| c.name }
+ to_column_names = columns(to).map(&:name)
columns = index.columns.map {|c| rename[c] || c }.select do |column|
to_column_names.include?(column)
end
@@ -586,7 +586,7 @@ module ActiveRecord
def copy_table_contents(from, to, columns, rename = {}) #:nodoc:
column_mappings = Hash[columns.map {|name| [name, name]}]
rename.each { |a| column_mappings[a.last] = a.first }
- from_columns = columns(from).collect {|col| col.name}
+ from_columns = columns(from).collect(&:name)
columns = columns.find_all{|col| from_columns.include?(column_mappings[col])}
quoted_columns = columns.map { |col| quote_column_name(col) } * ','
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 7c53ee0a9a..4732462b05 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -745,7 +745,7 @@ module ActiveRecord
end
def column_names
- @column_names ||= @connection.columns(@table_name).collect { |c| c.name }
+ @column_names ||= @connection.columns(@table_name).collect(&:name)
end
def read_fixture_files(path, model_class)
@@ -868,7 +868,7 @@ module ActiveRecord
fixture_set_names = Dir["#{fixture_path}/{**,*}/*.{yml}"]
fixture_set_names.map! { |f| f[(fixture_path.to_s.size + 1)..-5] }
else
- fixture_set_names = fixture_set_names.flatten.map { |n| n.to_s }
+ fixture_set_names = fixture_set_names.flatten.map(&:to_s)
end
self.fixture_table_names |= fixture_set_names
@@ -908,7 +908,7 @@ module ActiveRecord
def uses_transaction(*methods)
@uses_transaction = [] unless defined?(@uses_transaction)
- @uses_transaction.concat methods.map { |m| m.to_s }
+ @uses_transaction.concat methods.map(&:to_s)
end
def uses_transaction?(method)
diff --git a/activerecord/lib/active_record/gem_version.rb b/activerecord/lib/active_record/gem_version.rb
index e820835626..a388b529c9 100644
--- a/activerecord/lib/active_record/gem_version.rb
+++ b/activerecord/lib/active_record/gem_version.rb
@@ -5,10 +5,10 @@ module ActiveRecord
end
module VERSION
- MAJOR = 4
- MINOR = 2
+ MAJOR = 5
+ MINOR = 0
TINY = 0
- PRE = "beta4"
+ PRE = "alpha"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end
diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb
index f58145ab05..b91e9ac137 100644
--- a/activerecord/lib/active_record/inheritance.rb
+++ b/activerecord/lib/active_record/inheritance.rb
@@ -192,7 +192,7 @@ module ActiveRecord
def type_condition(table = arel_table)
sti_column = table[inheritance_column]
- sti_names = ([self] + descendants).map { |model| model.sti_name }
+ sti_names = ([self] + descendants).map(&:sti_name)
sti_column.in(sti_names)
end
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb
index 92f2951f2d..3cac465440 100644
--- a/activerecord/lib/active_record/migration.rb
+++ b/activerecord/lib/active_record/migration.rb
@@ -647,7 +647,7 @@ module ActiveRecord
end
def method_missing(method, *arguments, &block)
- arg_list = arguments.map{ |a| a.inspect } * ', '
+ arg_list = arguments.map(&:inspect) * ', '
say_with_time "#{method}(#{arg_list})" do
unless @connection.respond_to? :revert
diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb
index adad7774b9..92ad9c9101 100644
--- a/activerecord/lib/active_record/model_schema.rb
+++ b/activerecord/lib/active_record/model_schema.rb
@@ -257,7 +257,7 @@ module ActiveRecord
# Returns an array of column names as strings.
def column_names
- @column_names ||= columns.map { |column| column.name }
+ @column_names ||= columns.map(&:name)
end
# Returns an array of column objects where the primary id, all columns ending in "_id" or "_count",
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake
index 21b1c3f721..6c09456c4d 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -366,7 +366,7 @@ namespace :railties do
namespace :install do
# desc "Copies missing migrations from Railties (e.g. engines). You can specify Railties to use with FROM=railtie1,railtie2"
task :migrations => :'db:load_config' do
- to_load = ENV['FROM'].blank? ? :all : ENV['FROM'].split(",").map {|n| n.strip }
+ to_load = ENV['FROM'].blank? ? :all : ENV['FROM'].split(",").map(&:strip)
railties = {}
Rails.application.migration_railties.each do |railtie|
next unless to_load == :all || to_load.include?(railtie.railtie_name)
diff --git a/activerecord/lib/active_record/readonly_attributes.rb b/activerecord/lib/active_record/readonly_attributes.rb
index 85bbac43e4..ce78f1756d 100644
--- a/activerecord/lib/active_record/readonly_attributes.rb
+++ b/activerecord/lib/active_record/readonly_attributes.rb
@@ -11,7 +11,7 @@ module ActiveRecord
# Attributes listed as readonly will be used to create a new record but update operations will
# ignore these fields.
def attr_readonly(*attributes)
- self._attr_readonly = Set.new(attributes.map { |a| a.to_s }) + (self._attr_readonly || [])
+ self._attr_readonly = Set.new(attributes.map(&:to_s)) + (self._attr_readonly || [])
end
# Returns an array of all the attributes that have been specified as readonly.
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 4219632596..96520d1d49 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -791,7 +791,7 @@ module ActiveRecord
def source_reflection_name # :nodoc:
return @source_reflection_name if @source_reflection_name
- names = [name.to_s.singularize, name].collect { |n| n.to_sym }.uniq
+ names = [name.to_s.singularize, name].collect(&:to_sym).uniq
names = names.find_all { |n|
through_reflection.klass._reflect_on_association(n)
}
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 561ed222d1..7e1994086f 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -400,7 +400,7 @@ module ActiveRecord
if conditions
where(conditions).destroy_all
else
- to_a.each {|object| object.destroy }.tap { reset }
+ to_a.each(&:destroy).tap { reset }
end
end
@@ -644,7 +644,7 @@ module ActiveRecord
preloader.preload @records, associations
end
- @records.each { |record| record.readonly! } if readonly_value
+ @records.each(&:readonly!) if readonly_value
@loaded = true
@records
@@ -666,7 +666,7 @@ module ActiveRecord
joined_tables += [table.name, table.table_alias]
# always convert table names to downcase as in Oracle quoted table names are in uppercase
- joined_tables = joined_tables.flatten.compact.map { |t| t.downcase }.uniq
+ joined_tables = joined_tables.flatten.compact.map(&:downcase).uniq
(references_values - joined_tables).any?
end
@@ -675,7 +675,7 @@ module ActiveRecord
return [] if string.blank?
# always convert table names to downcase as in Oracle quoted table names are in uppercase
# ignore raw_sql_ that is used by Oracle adapter as alias for limit/offset subqueries
- string.scan(/([a-zA-Z_][.\w]+).?\./).flatten.map{ |s| s.downcase }.uniq - ['raw_sql_']
+ string.scan(/([a-zA-Z_][.\w]+).?\./).flatten.map(&:downcase).uniq - ['raw_sql_']
end
end
end
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index eacae73ebb..5061940d82 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -415,7 +415,7 @@ module ActiveRecord
end
def using_limitable_reflections?(reflections)
- reflections.none? { |r| r.collection? }
+ reflections.none?(&:collection?)
end
protected
diff --git a/activerecord/lib/active_record/serialization.rb b/activerecord/lib/active_record/serialization.rb
index bd9079b596..48c12dcf9f 100644
--- a/activerecord/lib/active_record/serialization.rb
+++ b/activerecord/lib/active_record/serialization.rb
@@ -11,7 +11,7 @@ module ActiveRecord #:nodoc:
def serializable_hash(options = nil)
options = options.try(:clone) || {}
- options[:except] = Array(options[:except]).map { |n| n.to_s }
+ options[:except] = Array(options[:except]).map(&:to_s)
options[:except] |= Array(self.class.inheritance_column)
super(options)
diff --git a/activerecord/lib/active_record/statement_cache.rb b/activerecord/lib/active_record/statement_cache.rb
index c68990bf99..192a19f05d 100644
--- a/activerecord/lib/active_record/statement_cache.rb
+++ b/activerecord/lib/active_record/statement_cache.rb
@@ -79,7 +79,7 @@ module ActiveRecord
end
def bind(values)
- bvs = @bind_values.map { |pair| pair.dup }
+ bvs = @bind_values.map(&:dup)
@indexes.each_with_index { |offset,i| bvs[offset][1] = values[i] }
bvs
end
diff --git a/activerecord/lib/active_record/validations/presence.rb b/activerecord/lib/active_record/validations/presence.rb
index c7aa814ba8..61b30749d9 100644
--- a/activerecord/lib/active_record/validations/presence.rb
+++ b/activerecord/lib/active_record/validations/presence.rb
@@ -8,7 +8,7 @@ module ActiveRecord
associated_records = Array.wrap(record.send(attribute))
# Superclass validates presence. Ensure present records aren't about to be destroyed.
- if associated_records.present? && associated_records.all? { |r| r.marked_for_destruction? }
+ if associated_records.present? && associated_records.all?(&:marked_for_destruction?)
record.errors.add(attribute, :blank, options)
end
end
diff --git a/activerecord/test/cases/adapters/mysql/connection_test.rb b/activerecord/test/cases/adapters/mysql/connection_test.rb
index 52eebe1886..ce01b16362 100644
--- a/activerecord/test/cases/adapters/mysql/connection_test.rb
+++ b/activerecord/test/cases/adapters/mysql/connection_test.rb
@@ -47,9 +47,7 @@ class MysqlConnectionTest < ActiveRecord::TestCase
assert !@connection.active?
# Repair all fixture connections so other tests won't break.
- @fixture_connections.each do |c|
- c.verify!
- end
+ @fixture_connections.each(&:verify!)
end
def test_successful_reconnection_after_timeout_with_manual_reconnect
diff --git a/activerecord/test/cases/adapters/mysql/reserved_word_test.rb b/activerecord/test/cases/adapters/mysql/reserved_word_test.rb
index 61ae0abfd1..403f7cbc74 100644
--- a/activerecord/test/cases/adapters/mysql/reserved_word_test.rb
+++ b/activerecord/test/cases/adapters/mysql/reserved_word_test.rb
@@ -101,7 +101,7 @@ class MysqlReservedWordTest < ActiveRecord::TestCase
gs = nil
assert_nothing_raised { gs = Select.find(2).groups }
assert_equal gs.length, 2
- assert(gs.collect{|x| x.id}.sort == [2, 3])
+ assert(gs.collect(&:id).sort == [2, 3])
end
# has_and_belongs_to_many with reserved-word table name
@@ -110,7 +110,7 @@ class MysqlReservedWordTest < ActiveRecord::TestCase
s = nil
assert_nothing_raised { s = Distinct.find(1).selects }
assert_equal s.length, 2
- assert(s.collect{|x|x.id}.sort == [1, 2])
+ assert(s.collect(&:id).sort == [1, 2])
end
# activerecord model introspection with reserved-word table and column names
diff --git a/activerecord/test/cases/adapters/mysql/schema_test.rb b/activerecord/test/cases/adapters/mysql/schema_test.rb
index 87c5277e64..ab547747df 100644
--- a/activerecord/test/cases/adapters/mysql/schema_test.rb
+++ b/activerecord/test/cases/adapters/mysql/schema_test.rb
@@ -81,7 +81,7 @@ module ActiveRecord
table = 'key_tests'
- indexes = @connection.indexes(table).sort_by {|i| i.name}
+ indexes = @connection.indexes(table).sort_by(&:name)
assert_equal 3,indexes.size
index_a = indexes.select{|i| i.name == index_a_name}[0]
diff --git a/activerecord/test/cases/adapters/mysql2/connection_test.rb b/activerecord/test/cases/adapters/mysql2/connection_test.rb
index 62c5abbf41..d261e2db55 100644
--- a/activerecord/test/cases/adapters/mysql2/connection_test.rb
+++ b/activerecord/test/cases/adapters/mysql2/connection_test.rb
@@ -44,9 +44,7 @@ class MysqlConnectionTest < ActiveRecord::TestCase
assert !@connection.active?
# Repair all fixture connections so other tests won't break.
- @fixture_connections.each do |c|
- c.verify!
- end
+ @fixture_connections.each(&:verify!)
end
def test_successful_reconnection_after_timeout_with_manual_reconnect
diff --git a/activerecord/test/cases/adapters/mysql2/reserved_word_test.rb b/activerecord/test/cases/adapters/mysql2/reserved_word_test.rb
index 799d927ee4..7f97b454bb 100644
--- a/activerecord/test/cases/adapters/mysql2/reserved_word_test.rb
+++ b/activerecord/test/cases/adapters/mysql2/reserved_word_test.rb
@@ -100,7 +100,7 @@ class MysqlReservedWordTest < ActiveRecord::TestCase
gs = nil
assert_nothing_raised { gs = Select.find(2).groups }
assert_equal gs.length, 2
- assert(gs.collect{|x| x.id}.sort == [2, 3])
+ assert(gs.collect(&:id).sort == [2, 3])
end
# has_and_belongs_to_many with reserved-word table name
@@ -109,7 +109,7 @@ class MysqlReservedWordTest < ActiveRecord::TestCase
s = nil
assert_nothing_raised { s = Distinct.find(1).selects }
assert_equal s.length, 2
- assert(s.collect{|x|x.id}.sort == [1, 2])
+ assert(s.collect(&:id).sort == [1, 2])
end
# activerecord model introspection with reserved-word table and column names
diff --git a/activerecord/test/cases/adapters/mysql2/schema_test.rb b/activerecord/test/cases/adapters/mysql2/schema_test.rb
index 1b7e60565d..47707b7d4f 100644
--- a/activerecord/test/cases/adapters/mysql2/schema_test.rb
+++ b/activerecord/test/cases/adapters/mysql2/schema_test.rb
@@ -51,7 +51,7 @@ module ActiveRecord
table = 'key_tests'
- indexes = @connection.indexes(table).sort_by {|i| i.name}
+ indexes = @connection.indexes(table).sort_by(&:name)
assert_equal 3,indexes.size
index_a = indexes.select{|i| i.name == index_a_name}[0]
diff --git a/activerecord/test/cases/adapters/postgresql/connection_test.rb b/activerecord/test/cases/adapters/postgresql/connection_test.rb
index 7d179944d4..ab7fd3c6d5 100644
--- a/activerecord/test/cases/adapters/postgresql/connection_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/connection_test.rb
@@ -177,9 +177,7 @@ module ActiveRecord
"successfully querying with the same connection pid."
# Repair all fixture connections so other tests won't break.
- @fixture_connections.each do |c|
- c.verify!
- end
+ @fixture_connections.each(&:verify!)
end
def test_set_session_variable_true
diff --git a/activerecord/test/cases/adapters/postgresql/schema_test.rb b/activerecord/test/cases/adapters/postgresql/schema_test.rb
index 350cb3e065..92c9a13ee3 100644
--- a/activerecord/test/cases/adapters/postgresql/schema_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/schema_test.rb
@@ -412,7 +412,7 @@ class SchemaTest < ActiveRecord::TestCase
def do_dump_index_tests_for_schema(this_schema_name, first_index_column_name, second_index_column_name, third_index_column_name, fourth_index_column_name)
with_schema_search_path(this_schema_name) do
- indexes = @connection.indexes(TABLE_NAME).sort_by {|i| i.name}
+ indexes = @connection.indexes(TABLE_NAME).sort_by(&:name)
assert_equal 4,indexes.size
do_dump_index_assertions_for_one_index(indexes[0], INDEX_A_NAME, first_index_column_name)
diff --git a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
index d83c65cf0e..9d09ff49c7 100644
--- a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
+++ b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
@@ -327,11 +327,11 @@ module ActiveRecord
def test_columns
with_example_table do
- columns = @conn.columns('ex').sort_by { |x| x.name }
+ columns = @conn.columns('ex').sort_by(&:name)
assert_equal 2, columns.length
- assert_equal %w{ id number }.sort, columns.map { |x| x.name }
- assert_equal [nil, nil], columns.map { |x| x.default }
- assert_equal [true, true], columns.map { |x| x.null }
+ assert_equal %w{ id number }.sort, columns.map(&:name)
+ assert_equal [nil, nil], columns.map(&:default)
+ assert_equal [true, true], columns.map(&:null)
end
end
diff --git a/activerecord/test/cases/associations/eager_load_nested_include_test.rb b/activerecord/test/cases/associations/eager_load_nested_include_test.rb
index 0ff87d53ea..f571198079 100644
--- a/activerecord/test/cases/associations/eager_load_nested_include_test.rb
+++ b/activerecord/test/cases/associations/eager_load_nested_include_test.rb
@@ -70,9 +70,7 @@ class EagerLoadPolyAssocsTest < ActiveRecord::TestCase
teardown do
[Circle, Square, Triangle, PaintColor, PaintTexture,
- ShapeExpression, NonPolyOne, NonPolyTwo].each do |c|
- c.delete_all
- end
+ ShapeExpression, NonPolyOne, NonPolyTwo].each(&:delete_all)
end
def generate_test_object_graphs
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index f968a34886..4321a198ca 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -338,31 +338,31 @@ class EagerAssociationTest < ActiveRecord::TestCase
def test_eager_association_loading_with_belongs_to_and_limit
comments = Comment.all.merge!(:includes => :post, :limit => 5, :order => 'comments.id').to_a
assert_equal 5, comments.length
- assert_equal [1,2,3,5,6], comments.collect { |c| c.id }
+ assert_equal [1,2,3,5,6], comments.collect(&:id)
end
def test_eager_association_loading_with_belongs_to_and_limit_and_conditions
comments = Comment.all.merge!(:includes => :post, :where => 'post_id = 4', :limit => 3, :order => 'comments.id').to_a
assert_equal 3, comments.length
- assert_equal [5,6,7], comments.collect { |c| c.id }
+ assert_equal [5,6,7], comments.collect(&:id)
end
def test_eager_association_loading_with_belongs_to_and_limit_and_offset
comments = Comment.all.merge!(:includes => :post, :limit => 3, :offset => 2, :order => 'comments.id').to_a
assert_equal 3, comments.length
- assert_equal [3,5,6], comments.collect { |c| c.id }
+ assert_equal [3,5,6], comments.collect(&:id)
end
def test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_conditions
comments = Comment.all.merge!(:includes => :post, :where => 'post_id = 4', :limit => 3, :offset => 1, :order => 'comments.id').to_a
assert_equal 3, comments.length
- assert_equal [6,7,8], comments.collect { |c| c.id }
+ assert_equal [6,7,8], comments.collect(&:id)
end
def test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_conditions_array
comments = Comment.all.merge!(:includes => :post, :where => ['post_id = ?',4], :limit => 3, :offset => 1, :order => 'comments.id').to_a
assert_equal 3, comments.length
- assert_equal [6,7,8], comments.collect { |c| c.id }
+ assert_equal [6,7,8], comments.collect(&:id)
end
def test_eager_association_loading_with_belongs_to_and_conditions_string_with_unquoted_table_name
@@ -377,7 +377,7 @@ class EagerAssociationTest < ActiveRecord::TestCase
comments = Comment.all.merge!(:includes => :post, :where => {:posts => {:id => 4}}, :limit => 3, :order => 'comments.id').to_a
end
assert_equal 3, comments.length
- assert_equal [5,6,7], comments.collect { |c| c.id }
+ assert_equal [5,6,7], comments.collect(&:id)
assert_no_queries do
comments.first.post
end
@@ -406,13 +406,13 @@ class EagerAssociationTest < ActiveRecord::TestCase
def test_eager_association_loading_with_belongs_to_and_limit_and_multiple_associations
posts = Post.all.merge!(:includes => [:author, :very_special_comment], :limit => 1, :order => 'posts.id').to_a
assert_equal 1, posts.length
- assert_equal [1], posts.collect { |p| p.id }
+ assert_equal [1], posts.collect(&:id)
end
def test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_multiple_associations
posts = Post.all.merge!(:includes => [:author, :very_special_comment], :limit => 1, :offset => 1, :order => 'posts.id').to_a
assert_equal 1, posts.length
- assert_equal [2], posts.collect { |p| p.id }
+ assert_equal [2], posts.collect(&:id)
end
def test_eager_association_loading_with_belongs_to_inferred_foreign_key_from_association_name
@@ -545,13 +545,13 @@ class EagerAssociationTest < ActiveRecord::TestCase
def test_eager_with_has_many_and_limit_and_conditions
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => "posts.body = 'hello'", :order => "posts.id").to_a
assert_equal 2, posts.size
- assert_equal [4,5], posts.collect { |p| p.id }
+ assert_equal [4,5], posts.collect(&:id)
end
def test_eager_with_has_many_and_limit_and_conditions_array
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => [ "posts.body = ?", 'hello' ], :order => "posts.id").to_a
assert_equal 2, posts.size
- assert_equal [4,5], posts.collect { |p| p.id }
+ assert_equal [4,5], posts.collect(&:id)
end
def test_eager_with_has_many_and_limit_and_conditions_array_on_the_eagers
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
index 092e85949c..aea9207bfe 100644
--- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -555,7 +555,7 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
def test_dynamic_find_all_should_respect_readonly_access
projects(:active_record).readonly_developers.each { |d| assert_raise(ActiveRecord::ReadOnlyRecord) { d.save! } if d.valid?}
- projects(:active_record).readonly_developers.each { |d| d.readonly? }
+ projects(:active_record).readonly_developers.each(&:readonly?)
end
def test_new_with_values_in_collection
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 9510d57de6..c075872617 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -1219,7 +1219,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert !clients.empty?, "37signals has clients after load"
destroyed = companies(:first_firm).clients_of_firm.destroy_all
assert_equal clients.sort_by(&:id), destroyed.sort_by(&:id)
- assert destroyed.all? { |client| client.frozen? }, "destroyed clients should be frozen"
+ assert destroyed.all?(&:frozen?), "destroyed clients should be frozen"
assert companies(:first_firm).clients_of_firm.empty?, "37signals has no clients after destroy all"
assert companies(:first_firm).clients_of_firm(true).empty?, "37signals has no clients after destroy all and refresh"
end
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb
index d523ea4f07..589a232bdb 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -41,7 +41,7 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
def test_preload_sti_rhs_class
developers = Developer.includes(:firms).all.to_a
assert_no_queries do
- developers.each { |d| d.firms }
+ developers.each(&:firms)
end
end
diff --git a/activerecord/test/cases/associations/inner_join_association_test.rb b/activerecord/test/cases/associations/inner_join_association_test.rb
index 07cf65a760..9938302885 100644
--- a/activerecord/test/cases/associations/inner_join_association_test.rb
+++ b/activerecord/test/cases/associations/inner_join_association_test.rb
@@ -54,7 +54,7 @@ class InnerJoinAssociationTest < ActiveRecord::TestCase
def test_find_with_implicit_inner_joins_without_select_does_not_imply_readonly
authors = Author.joins(:posts)
assert_not authors.empty?, "expected authors to be non-empty"
- assert authors.none? {|a| a.readonly? }, "expected no authors to be readonly"
+ assert authors.none?(&:readonly?), "expected no authors to be readonly"
end
def test_find_with_implicit_inner_joins_honors_readonly_with_select
diff --git a/activerecord/test/cases/associations/join_model_test.rb b/activerecord/test/cases/associations/join_model_test.rb
index cace7ba142..140ccdac72 100644
--- a/activerecord/test/cases/associations/join_model_test.rb
+++ b/activerecord/test/cases/associations/join_model_test.rb
@@ -393,18 +393,18 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase
end
def test_has_many_through_polymorphic_has_one
- assert_equal Tagging.find(1,2).sort_by { |t| t.id }, authors(:david).taggings_2
+ assert_equal Tagging.find(1,2).sort_by(&:id), authors(:david).taggings_2
end
def test_has_many_through_polymorphic_has_many
- assert_equal taggings(:welcome_general, :thinking_general), authors(:david).taggings.distinct.sort_by { |t| t.id }
+ assert_equal taggings(:welcome_general, :thinking_general), authors(:david).taggings.distinct.sort_by(&:id)
end
def test_include_has_many_through_polymorphic_has_many
author = Author.includes(:taggings).find authors(:david).id
expected_taggings = taggings(:welcome_general, :thinking_general)
assert_no_queries do
- assert_equal expected_taggings, author.taggings.distinct.sort_by { |t| t.id }
+ assert_equal expected_taggings, author.taggings.distinct.sort_by(&:id)
end
end
diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb
index 04ef50e58a..c6769edcbf 100644
--- a/activerecord/test/cases/associations_test.rb
+++ b/activerecord/test/cases/associations_test.rb
@@ -48,7 +48,7 @@ class AssociationsTest < ActiveRecord::TestCase
assert_kind_of Firm, firm
firm.clear_association_cache
- assert_equal Firm.find(1).clients.collect{ |x| x.name }.sort, firm.clients.collect{ |x| x.name }.sort
+ assert_equal Firm.find(1).clients.collect(&:name).sort, firm.clients.collect(&:name).sort
end
def test_clear_association_cache_new_record
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index 71c34d816a..04d5a2869c 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -774,13 +774,13 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase
def test_should_destroy_has_many_as_part_of_the_save_transaction_if_they_were_marked_for_destruction
2.times { |i| @pirate.birds.create!(:name => "birds_#{i}") }
- assert !@pirate.birds.any? { |child| child.marked_for_destruction? }
+ assert !@pirate.birds.any?(&:marked_for_destruction?)
- @pirate.birds.each { |child| child.mark_for_destruction }
+ @pirate.birds.each(&:mark_for_destruction)
klass = @pirate.birds.first.class
ids = @pirate.birds.map(&:id)
- assert @pirate.birds.all? { |child| child.marked_for_destruction? }
+ assert @pirate.birds.all?(&:marked_for_destruction?)
ids.each { |id| assert klass.find_by_id(id) }
@pirate.save
@@ -814,14 +814,14 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase
@pirate.birds.each { |bird| bird.name = '' }
assert !@pirate.valid?
- @pirate.birds.each { |bird| bird.destroy }
+ @pirate.birds.each(&:destroy)
assert @pirate.valid?
end
def test_a_child_marked_for_destruction_should_not_be_destroyed_twice_while_saving_has_many
@pirate.birds.create!(:name => "birds_1")
- @pirate.birds.each { |bird| bird.mark_for_destruction }
+ @pirate.birds.each(&:mark_for_destruction)
assert @pirate.save
@pirate.birds.each { |bird| bird.expects(:destroy).never }
@@ -888,7 +888,7 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase
association_name_with_callbacks = "birds_with_#{callback_type}_callbacks"
@pirate.send(association_name_with_callbacks).create!(:name => "Crowe the One-Eyed")
- @pirate.send(association_name_with_callbacks).each { |c| c.mark_for_destruction }
+ @pirate.send(association_name_with_callbacks).each(&:mark_for_destruction)
child_id = @pirate.send(association_name_with_callbacks).first.id
@pirate.ship_log.clear
@@ -906,8 +906,8 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase
def test_should_destroy_habtm_as_part_of_the_save_transaction_if_they_were_marked_for_destruction
2.times { |i| @pirate.parrots.create!(:name => "parrots_#{i}") }
- assert !@pirate.parrots.any? { |parrot| parrot.marked_for_destruction? }
- @pirate.parrots.each { |parrot| parrot.mark_for_destruction }
+ assert !@pirate.parrots.any?(&:marked_for_destruction?)
+ @pirate.parrots.each(&:mark_for_destruction)
assert_no_difference "Parrot.count" do
@pirate.save
@@ -940,14 +940,14 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase
@pirate.parrots.each { |parrot| parrot.name = '' }
assert !@pirate.valid?
- @pirate.parrots.each { |parrot| parrot.destroy }
+ @pirate.parrots.each(&:destroy)
assert @pirate.valid?
end
def test_a_child_marked_for_destruction_should_not_be_destroyed_twice_while_saving_habtm
@pirate.parrots.create!(:name => "parrots_1")
- @pirate.parrots.each { |parrot| parrot.mark_for_destruction }
+ @pirate.parrots.each(&:mark_for_destruction)
assert @pirate.save
Pirate.transaction do
@@ -992,7 +992,7 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase
association_name_with_callbacks = "parrots_with_#{callback_type}_callbacks"
@pirate.send(association_name_with_callbacks).create!(:name => "Crowe the One-Eyed")
- @pirate.send(association_name_with_callbacks).each { |c| c.mark_for_destruction }
+ @pirate.send(association_name_with_callbacks).each(&:mark_for_destruction)
child_id = @pirate.send(association_name_with_callbacks).first.id
@pirate.ship_log.clear
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 33a59d4678..a607c1319f 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -934,7 +934,7 @@ class FinderTest < ActiveRecord::TestCase
joins('LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id').
where('project_id=1').to_a
assert_equal 3, developers_on_project_one.length
- developer_names = developers_on_project_one.map { |d| d.name }
+ developer_names = developers_on_project_one.map(&:name)
assert developer_names.include?('David')
assert developer_names.include?('Jamis')
end
@@ -989,7 +989,7 @@ class FinderTest < ActiveRecord::TestCase
end
def test_select_values
- assert_equal ["1","2","3","4","5","6","7","8","9", "10", "11"], Company.connection.select_values("SELECT id FROM companies ORDER BY id").map! { |i| i.to_s }
+ assert_equal ["1","2","3","4","5","6","7","8","9", "10", "11"], Company.connection.select_values("SELECT id FROM companies ORDER BY id").map!(&:to_s)
assert_equal ["37signals","Summit","Microsoft", "Flamboyant Software", "Ex Nihilo", "RailsCore", "Leetsoft", "Jadedpixel", "Odegy", "Ex Nihilo Part Deux", "Apex"], Company.connection.select_values("SELECT name FROM companies ORDER BY id")
end
@@ -1015,7 +1015,7 @@ class FinderTest < ActiveRecord::TestCase
where(client_of: [2, 1, nil],
name: ['37signals', 'Summit', 'Microsoft']).
order('client_of DESC').
- map { |x| x.client_of }
+ map(&:client_of)
assert client_of.include?(nil)
assert_equal [2, 1].sort, client_of.compact.sort
@@ -1025,7 +1025,7 @@ class FinderTest < ActiveRecord::TestCase
client_of = Company.
where(client_of: [nil]).
order('client_of DESC').
- map { |x| x.client_of }
+ map(&:client_of)
assert_equal [], client_of.compact
end
diff --git a/activerecord/test/cases/migration/column_positioning_test.rb b/activerecord/test/cases/migration/column_positioning_test.rb
index 77a752f050..62186e13a5 100644
--- a/activerecord/test/cases/migration/column_positioning_test.rb
+++ b/activerecord/test/cases/migration/column_positioning_test.rb
@@ -25,30 +25,30 @@ module ActiveRecord
if current_adapter?(:MysqlAdapter, :Mysql2Adapter)
def test_column_positioning
- assert_equal %w(first second third), conn.columns(:testings).map {|c| c.name }
+ assert_equal %w(first second third), conn.columns(:testings).map(&:name)
end
def test_add_column_with_positioning
conn.add_column :testings, :new_col, :integer
- assert_equal %w(first second third new_col), conn.columns(:testings).map {|c| c.name }
+ assert_equal %w(first second third new_col), conn.columns(:testings).map(&:name)
end
def test_add_column_with_positioning_first
conn.add_column :testings, :new_col, :integer, :first => true
- assert_equal %w(new_col first second third), conn.columns(:testings).map {|c| c.name }
+ assert_equal %w(new_col first second third), conn.columns(:testings).map(&:name)
end
def test_add_column_with_positioning_after
conn.add_column :testings, :new_col, :integer, :after => :first
- assert_equal %w(first new_col second third), conn.columns(:testings).map {|c| c.name }
+ assert_equal %w(first new_col second third), conn.columns(:testings).map(&:name)
end
def test_change_column_with_positioning
conn.change_column :testings, :second, :integer, :first => true
- assert_equal %w(second first third), conn.columns(:testings).map {|c| c.name }
+ assert_equal %w(second first third), conn.columns(:testings).map(&:name)
conn.change_column :testings, :second, :integer, :after => :third
- assert_equal %w(first third second), conn.columns(:testings).map {|c| c.name }
+ assert_equal %w(first third second), conn.columns(:testings).map(&:name)
end
end
end
diff --git a/activerecord/test/cases/migrator_test.rb b/activerecord/test/cases/migrator_test.rb
index f05ca900aa..c0daa83e9c 100644
--- a/activerecord/test/cases/migrator_test.rb
+++ b/activerecord/test/cases/migrator_test.rb
@@ -149,7 +149,7 @@ class MigratorTest < ActiveRecord::TestCase
def test_up_calls_up
migrations = [Sensor.new(nil, 0), Sensor.new(nil, 1), Sensor.new(nil, 2)]
ActiveRecord::Migrator.new(:up, migrations).migrate
- assert migrations.all? { |m| m.went_up }
+ assert migrations.all?(&:went_up)
assert migrations.all? { |m| !m.went_down }
assert_equal 2, ActiveRecord::Migrator.current_version
end
@@ -160,7 +160,7 @@ class MigratorTest < ActiveRecord::TestCase
migrations = [Sensor.new(nil, 0), Sensor.new(nil, 1), Sensor.new(nil, 2)]
ActiveRecord::Migrator.new(:down, migrations).migrate
assert migrations.all? { |m| !m.went_up }
- assert migrations.all? { |m| m.went_down }
+ assert migrations.all?(&:went_down)
assert_equal 0, ActiveRecord::Migrator.current_version
end
diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb
index cf96c3fccf..5c7e8a65d2 100644
--- a/activerecord/test/cases/nested_attributes_test.rb
+++ b/activerecord/test/cases/nested_attributes_test.rb
@@ -13,7 +13,7 @@ require 'active_support/hash_with_indifferent_access'
class TestNestedAttributesInGeneral < ActiveRecord::TestCase
teardown do
- Pirate.accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
+ Pirate.accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc(&:empty?)
end
def test_base_should_have_an_empty_nested_attributes_options
@@ -300,13 +300,13 @@ class TestNestedAttributesOnAHasOneAssociation < ActiveRecord::TestCase
end
def test_should_not_destroy_an_existing_record_if_allow_destroy_is_false
- Pirate.accepts_nested_attributes_for :ship, :allow_destroy => false, :reject_if => proc { |attributes| attributes.empty? }
+ Pirate.accepts_nested_attributes_for :ship, :allow_destroy => false, :reject_if => proc(&:empty?)
@pirate.update(ship_attributes: { id: @pirate.ship.id, _destroy: '1' })
assert_equal @ship, @pirate.reload.ship
- Pirate.accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
+ Pirate.accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc(&:empty?)
end
def test_should_also_work_with_a_HashWithIndifferentAccess
@@ -494,12 +494,12 @@ class TestNestedAttributesOnABelongsToAssociation < ActiveRecord::TestCase
end
def test_should_not_destroy_an_existing_record_if_allow_destroy_is_false
- Ship.accepts_nested_attributes_for :pirate, :allow_destroy => false, :reject_if => proc { |attributes| attributes.empty? }
+ Ship.accepts_nested_attributes_for :pirate, :allow_destroy => false, :reject_if => proc(&:empty?)
@ship.update(pirate_attributes: { id: @ship.pirate.id, _destroy: '1' })
assert_nothing_raised(ActiveRecord::RecordNotFound) { @ship.pirate.reload }
ensure
- Ship.accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
+ Ship.accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc(&:empty?)
end
def test_should_work_with_update_as_well
@@ -855,7 +855,7 @@ end
module NestedAttributesLimitTests
def teardown
- Pirate.accepts_nested_attributes_for :parrots, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
+ Pirate.accepts_nested_attributes_for :parrots, :allow_destroy => true, :reject_if => proc(&:empty?)
end
def test_limit_with_less_records
diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb
index 2bcd496415..6fc4731f01 100644
--- a/activerecord/test/cases/persistence_test.rb
+++ b/activerecord/test/cases/persistence_test.rb
@@ -127,7 +127,7 @@ class PersistenceTest < ActiveRecord::TestCase
assert_difference('Topic.count', -topics_by_mary.size) do
destroyed = Topic.destroy_all(conditions).sort_by(&:id)
assert_equal topics_by_mary, destroyed
- assert destroyed.all? { |topic| topic.frozen? }, "destroyed topics should be frozen"
+ assert destroyed.all?(&:frozen?), "destroyed topics should be frozen"
end
end
@@ -137,7 +137,7 @@ class PersistenceTest < ActiveRecord::TestCase
assert_difference('Client.count', -2) do
destroyed = Client.destroy([2, 3]).sort_by(&:id)
assert_equal clients, destroyed
- assert destroyed.all? { |client| client.frozen? }, "destroyed clients should be frozen"
+ assert destroyed.all?(&:frozen?), "destroyed clients should be frozen"
end
end
diff --git a/activerecord/test/cases/pooled_connections_test.rb b/activerecord/test/cases/pooled_connections_test.rb
index 8eea10143f..98888150a8 100644
--- a/activerecord/test/cases/pooled_connections_test.rb
+++ b/activerecord/test/cases/pooled_connections_test.rb
@@ -13,7 +13,7 @@ class PooledConnectionsTest < ActiveRecord::TestCase
teardown do
ActiveRecord::Base.clear_all_connections!
ActiveRecord::Base.establish_connection(@connection)
- @per_test_teardown.each {|td| td.call }
+ @per_test_teardown.each(&:call)
end
# Will deadlock due to lack of Monitor timeouts in 1.9
diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb
index 094fcccc89..e86b892a0a 100644
--- a/activerecord/test/cases/reflection_test.rb
+++ b/activerecord/test/cases/reflection_test.rb
@@ -50,13 +50,13 @@ class ReflectionTest < ActiveRecord::TestCase
end
def test_columns_are_returned_in_the_order_they_were_declared
- column_names = Topic.columns.map { |column| column.name }
+ column_names = Topic.columns.map(&:name)
assert_equal %w(id title author_name author_email_address written_on bonus_time last_read content important approved replies_count unique_replies_count parent_id parent_title type group created_at updated_at), column_names
end
def test_content_columns
content_columns = Topic.content_columns
- content_column_names = content_columns.map {|column| column.name}
+ content_column_names = content_columns.map(&:name)
assert_equal 13, content_columns.length
assert_equal %w(title author_name author_email_address written_on bonus_time last_read content important group approved parent_title created_at updated_at).sort, content_column_names.sort
end
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index ca86d58b35..fc9637a167 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -249,7 +249,7 @@ class RelationTest < ActiveRecord::TestCase
def test_finding_with_reorder
topics = Topic.order('author_name').order('title').reorder('id').to_a
- topics_titles = topics.map{ |t| t.title }
+ topics_titles = topics.map(&:title)
assert_equal ['The First Topic', 'The Second Topic of the day', 'The Third Topic of the day', 'The Fourth Topic of the day', 'The Fifth Topic of the day'], topics_titles
end
@@ -441,7 +441,7 @@ class RelationTest < ActiveRecord::TestCase
where('project_id=1').to_a
assert_equal 3, developers_on_project_one.length
- developer_names = developers_on_project_one.map { |d| d.name }
+ developer_names = developers_on_project_one.map(&:name)
assert developer_names.include?('David')
assert developer_names.include?('Jamis')
end
@@ -652,8 +652,8 @@ class RelationTest < ActiveRecord::TestCase
expected_taggings = taggings(:welcome_general, :thinking_general)
assert_no_queries do
- assert_equal expected_taggings, author.taggings.distinct.sort_by { |t| t.id }
- assert_equal expected_taggings, author.taggings.uniq.sort_by { |t| t.id }
+ assert_equal expected_taggings, author.taggings.distinct.sort_by(&:id)
+ assert_equal expected_taggings, author.taggings.uniq.sort_by(&:id)
end
authors = Author.all
diff --git a/activerecord/test/cases/scoping/default_scoping_test.rb b/activerecord/test/cases/scoping/default_scoping_test.rb
index 880d0e8293..5bdebe6ac7 100644
--- a/activerecord/test/cases/scoping/default_scoping_test.rb
+++ b/activerecord/test/cases/scoping/default_scoping_test.rb
@@ -8,8 +8,8 @@ class DefaultScopingTest < ActiveRecord::TestCase
fixtures :developers, :posts, :comments
def test_default_scope
- expected = Developer.all.merge!(:order => 'salary DESC').to_a.collect { |dev| dev.salary }
- received = DeveloperOrderedBySalary.all.collect { |dev| dev.salary }
+ expected = Developer.all.merge!(:order => 'salary DESC').to_a.collect(&:salary)
+ received = DeveloperOrderedBySalary.all.collect(&:salary)
assert_equal expected, received
end
@@ -86,14 +86,14 @@ class DefaultScopingTest < ActiveRecord::TestCase
end
def test_scope_overwrites_default
- expected = Developer.all.merge!(order: 'salary DESC, name DESC').to_a.collect { |dev| dev.name }
- received = DeveloperOrderedBySalary.by_name.to_a.collect { |dev| dev.name }
+ expected = Developer.all.merge!(order: 'salary DESC, name DESC').to_a.collect(&:name)
+ received = DeveloperOrderedBySalary.by_name.to_a.collect(&:name)
assert_equal expected, received
end
def test_reorder_overrides_default_scope_order
- expected = Developer.order('name DESC').collect { |dev| dev.name }
- received = DeveloperOrderedBySalary.reorder('name DESC').collect { |dev| dev.name }
+ expected = Developer.order('name DESC').collect(&:name)
+ received = DeveloperOrderedBySalary.reorder('name DESC').collect(&:name)
assert_equal expected, received
end
@@ -146,34 +146,34 @@ class DefaultScopingTest < ActiveRecord::TestCase
end
def test_unscope_multiple_where_clauses
- expected = Developer.order('salary DESC').collect { |dev| dev.name }
- received = DeveloperOrderedBySalary.where(name: 'Jamis').where(id: 1).unscope(where: [:name, :id]).collect { |dev| dev.name }
+ expected = Developer.order('salary DESC').collect(&:name)
+ received = DeveloperOrderedBySalary.where(name: 'Jamis').where(id: 1).unscope(where: [:name, :id]).collect(&:name)
assert_equal expected, received
end
def test_unscope_string_where_clauses_involved
dev_relation = Developer.order('salary DESC').where("created_at > ?", 1.year.ago)
- expected = dev_relation.collect { |dev| dev.name }
+ expected = dev_relation.collect(&:name)
dev_ordered_relation = DeveloperOrderedBySalary.where(name: 'Jamis').where("created_at > ?", 1.year.ago)
- received = dev_ordered_relation.unscope(where: [:name]).collect { |dev| dev.name }
+ received = dev_ordered_relation.unscope(where: [:name]).collect(&:name)
assert_equal expected, received
end
def test_unscope_with_grouping_attributes
- expected = Developer.order('salary DESC').collect { |dev| dev.name }
- received = DeveloperOrderedBySalary.group(:name).unscope(:group).collect { |dev| dev.name }
+ expected = Developer.order('salary DESC').collect(&:name)
+ received = DeveloperOrderedBySalary.group(:name).unscope(:group).collect(&:name)
assert_equal expected, received
- expected_2 = Developer.order('salary DESC').collect { |dev| dev.name }
- received_2 = DeveloperOrderedBySalary.group("name").unscope(:group).collect { |dev| dev.name }
+ expected_2 = Developer.order('salary DESC').collect(&:name)
+ received_2 = DeveloperOrderedBySalary.group("name").unscope(:group).collect(&:name)
assert_equal expected_2, received_2
end
def test_unscope_with_limit_in_query
- expected = Developer.order('salary DESC').collect { |dev| dev.name }
- received = DeveloperOrderedBySalary.limit(1).unscope(:limit).collect { |dev| dev.name }
+ expected = Developer.order('salary DESC').collect(&:name)
+ received = DeveloperOrderedBySalary.limit(1).unscope(:limit).collect(&:name)
assert_equal expected, received
end
@@ -183,42 +183,42 @@ class DefaultScopingTest < ActiveRecord::TestCase
end
def test_unscope_reverse_order
- expected = Developer.all.collect { |dev| dev.name }
- received = Developer.order('salary DESC').reverse_order.unscope(:order).collect { |dev| dev.name }
+ expected = Developer.all.collect(&:name)
+ received = Developer.order('salary DESC').reverse_order.unscope(:order).collect(&:name)
assert_equal expected, received
end
def test_unscope_select
- expected = Developer.order('salary ASC').collect { |dev| dev.name }
- received = Developer.order('salary DESC').reverse_order.select(:name).unscope(:select).collect { |dev| dev.name }
+ expected = Developer.order('salary ASC').collect(&:name)
+ received = Developer.order('salary DESC').reverse_order.select(:name).unscope(:select).collect(&:name)
assert_equal expected, received
- expected_2 = Developer.all.collect { |dev| dev.id }
- received_2 = Developer.select(:name).unscope(:select).collect { |dev| dev.id }
+ expected_2 = Developer.all.collect(&:id)
+ received_2 = Developer.select(:name).unscope(:select).collect(&:id)
assert_equal expected_2, received_2
end
def test_unscope_offset
- expected = Developer.all.collect { |dev| dev.name }
- received = Developer.offset(5).unscope(:offset).collect { |dev| dev.name }
+ expected = Developer.all.collect(&:name)
+ received = Developer.offset(5).unscope(:offset).collect(&:name)
assert_equal expected, received
end
def test_unscope_joins_and_select_on_developers_projects
- expected = Developer.all.collect { |dev| dev.name }
- received = Developer.joins('JOIN developers_projects ON id = developer_id').select(:id).unscope(:joins, :select).collect { |dev| dev.name }
+ expected = Developer.all.collect(&:name)
+ received = Developer.joins('JOIN developers_projects ON id = developer_id').select(:id).unscope(:joins, :select).collect(&:name)
assert_equal expected, received
end
def test_unscope_includes
- expected = Developer.all.collect { |dev| dev.name }
- received = Developer.includes(:projects).select(:id).unscope(:includes, :select).collect { |dev| dev.name }
+ expected = Developer.all.collect(&:name)
+ received = Developer.includes(:projects).select(:id).unscope(:includes, :select).collect(&:name)
assert_equal expected, received
end
def test_unscope_having
- expected = DeveloperOrderedBySalary.all.collect { |dev| dev.name }
- received = DeveloperOrderedBySalary.having("name IN ('Jamis', 'David')").unscope(:having).collect { |dev| dev.name }
+ expected = DeveloperOrderedBySalary.all.collect(&:name)
+ received = DeveloperOrderedBySalary.having("name IN ('Jamis', 'David')").unscope(:having).collect(&:name)
assert_equal expected, received
end
@@ -281,8 +281,8 @@ class DefaultScopingTest < ActiveRecord::TestCase
end
def test_order_in_default_scope_should_not_prevail
- expected = Developer.all.merge!(order: 'salary desc').to_a.collect { |dev| dev.salary }
- received = DeveloperOrderedBySalary.all.merge!(order: 'salary').to_a.collect { |dev| dev.salary }
+ expected = Developer.all.merge!(order: 'salary desc').to_a.collect(&:salary)
+ received = DeveloperOrderedBySalary.all.merge!(order: 'salary').to_a.collect(&:salary)
assert_equal expected, received
end
diff --git a/activerecord/test/cases/test_case.rb b/activerecord/test/cases/test_case.rb
index eb44c4a83c..5ba17359f0 100644
--- a/activerecord/test/cases/test_case.rb
+++ b/activerecord/test/cases/test_case.rb
@@ -43,7 +43,7 @@ module ActiveRecord
patterns_to_match.each do |pattern|
failed_patterns << pattern unless SQLCounter.log_all.any?{ |sql| pattern === sql }
end
- assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map{ |p| p.inspect }.join(', ')} not found.#{SQLCounter.log.size == 0 ? '' : "\nQueries:\n#{SQLCounter.log.join("\n")}"}"
+ assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map(&:inspect).join(', ')} not found.#{SQLCounter.log.size == 0 ? '' : "\nQueries:\n#{SQLCounter.log.join("\n")}"}"
end
def assert_queries(num = 1, options = {})
diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb
index 7160e8324d..72c07d8aea 100644
--- a/activerecord/test/cases/transactions_test.rb
+++ b/activerecord/test/cases/transactions_test.rb
@@ -13,7 +13,7 @@ class TransactionTest < ActiveRecord::TestCase
fixtures :topics, :developers, :authors, :posts
def setup
- @first, @second = Topic.find(1, 2).sort_by { |t| t.id }
+ @first, @second = Topic.find(1, 2).sort_by(&:id)
end
def test_persisted_in_a_model_with_custom_primary_key_after_failed_save
@@ -699,7 +699,7 @@ if current_adapter?(:PostgreSQLAdapter)
end
end
- threads.each { |t| t.join }
+ threads.each(&:join)
end
end
@@ -747,7 +747,7 @@ if current_adapter?(:PostgreSQLAdapter)
Developer.connection.close
end
- threads.each { |t| t.join }
+ threads.each(&:join)
end
assert_equal original_salary, Developer.find(1).salary
diff --git a/activerecord/test/cases/validations_repair_helper.rb b/activerecord/test/cases/validations_repair_helper.rb
index 2bbf0f23b3..b30666d876 100644
--- a/activerecord/test/cases/validations_repair_helper.rb
+++ b/activerecord/test/cases/validations_repair_helper.rb
@@ -5,9 +5,7 @@ module ActiveRecord
module ClassMethods
def repair_validations(*model_classes)
teardown do
- model_classes.each do |k|
- k.clear_validators!
- end
+ model_classes.each(&:clear_validators!)
end
end
end
@@ -15,9 +13,7 @@ module ActiveRecord
def repair_validations(*model_classes)
yield if block_given?
ensure
- model_classes.each do |k|
- k.clear_validators!
- end
+ model_classes.each(&:clear_validators!)
end
end
end
diff --git a/activerecord/test/models/customer.rb b/activerecord/test/models/customer.rb
index 7e8e82542f..afe4b3d707 100644
--- a/activerecord/test/models/customer.rb
+++ b/activerecord/test/models/customer.rb
@@ -2,7 +2,7 @@ class Customer < ActiveRecord::Base
cattr_accessor :gps_conversion_was_run
composed_of :address, :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ], :allow_nil => true
- composed_of :balance, :class_name => "Money", :mapping => %w(balance amount), :converter => Proc.new { |balance| balance.to_money }
+ composed_of :balance, :class_name => "Money", :mapping => %w(balance amount), :converter => Proc.new(&:to_money)
composed_of :gps_location, :allow_nil => true
composed_of :non_blank_gps_location, :class_name => "GpsLocation", :allow_nil => true, :mapping => %w(gps_location gps_location),
:converter => lambda { |gps| self.gps_conversion_was_run = true; gps.blank? ? nil : GpsLocation.new(gps)}
diff --git a/activerecord/test/models/pirate.rb b/activerecord/test/models/pirate.rb
index 90a3c3ecee..641a33f9be 100644
--- a/activerecord/test/models/pirate.rb
+++ b/activerecord/test/models/pirate.rb
@@ -36,8 +36,8 @@ class Pirate < ActiveRecord::Base
has_one :foo_bulb, -> { where :name => 'foo' }, :foreign_key => :car_id, :class_name => "Bulb"
- accepts_nested_attributes_for :parrots, :birds, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
- accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
+ accepts_nested_attributes_for :parrots, :birds, :allow_destroy => true, :reject_if => proc(&:empty?)
+ accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc(&:empty?)
accepts_nested_attributes_for :update_only_ship, :update_only => true
accepts_nested_attributes_for :parrots_with_method_callbacks, :parrots_with_proc_callbacks,
:birds_with_method_callbacks, :birds_with_proc_callbacks, :allow_destroy => true
diff --git a/activerecord/test/models/ship.rb b/activerecord/test/models/ship.rb
index 77a4728d0b..5f618a50d2 100644
--- a/activerecord/test/models/ship.rb
+++ b/activerecord/test/models/ship.rb
@@ -6,7 +6,7 @@ class Ship < ActiveRecord::Base
has_many :parts, :class_name => 'ShipPart'
accepts_nested_attributes_for :parts, :allow_destroy => true
- accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
+ accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc(&:empty?)
accepts_nested_attributes_for :update_only_pirate, :update_only => true
validates_presence_of :name
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index ed30c7de70..810fc22cf5 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,388 +1 @@
-* The decorated `load` and `require` methods are now kept private.
-
- Fixes #17553.
-
- *Xavier Noria*
-
-* `String#remove` and `String#remove!` accept multiple arguments.
-
- *Pavel Pravosud*
-
-* `TimeWithZone#strftime` now delegates every directive to `Time#strftime` except for '%Z',
- it also now correctly handles escaped '%' characters placed just before time zone related directives.
-
- *Pablo Herrero*
-
-* Corrected `Inflector#underscore` handling of multiple successive acroynms.
-
- *James Le Cuirot*
-
-* Delegation now works with ruby reserved words passed to `:to` option.
-
- Fixes #16956.
-
- *Agis Anastasopoulos*
-
-* Added method `#eql?` to `ActiveSupport::Duration`, in addition to `#==`.
-
- Currently, the following returns `false`, contrary to expectation:
-
- 1.minute.eql?(1.minute)
-
- Adding method `#eql?` will make this behave like expected. Method `#eql?` is
- just a bit stricter than `#==`, as it checks whether the argument is also a duration. Their
- parts may be different though.
-
- 1.minute.eql?(60.seconds) # => true
- 1.minute.eql?(60) # => false
-
- *Joost Lubach*
-
-* `Time#change` can now change nanoseconds (`:nsec`) as a higher-precision
- alternative to microseconds (`:usec`).
-
- *Agis Anastasooulos*
-
-* `MessageVerifier.new` raises an appropriate exception if the secret is `nil`.
- This prevents `MessageVerifier#generate` from raising a cryptic error later on.
-
- *Kostiantyn Kahanskyi*
-
-* Introduced new configuration option `active_support.test_order` for
- specifying the order in which test cases are executed. This option currently defaults
- to `:sorted` but will be changed to `:random` in Rails 5.0.
-
- *Akira Matsuda*, *Godfrey Chan*
-
-* Fixed a bug in `Inflector#underscore` where acroynms in nested constant names
- are incorrectly parsed as camelCase.
-
- Fixes #8015.
-
- *Fred Wu*, *Matthew Draper*
-
-* Make `Time#change` throw an exception if the `:usec` option is out of range and
- the time has an offset other than UTC or local.
-
- *Agis Anastasopoulos*
-
-* `Method` objects now report themselves as not `duplicable?`. This allows
- hashes and arrays containing `Method` objects to be `deep_dup`ed.
-
- *Peter Jaros*
-
-* `determine_constant_from_test_name` does no longer shadow `NameError`s
- which happens during constant autoloading.
-
- Fixes #9933.
-
- *Guo Xiang Tan*
-
-* Added instance_eval version to Object#try and Object#try!, so you can do this:
-
- person.try { name.first }
-
- instead of:
-
- person.try { |person| person.name.first }
-
- *DHH*, *Ari Pollak*
-
-* Fix the `ActiveSupport::Duration#instance_of?` method to return the right
- value with the class itself since it was previously delegated to the
- internal value.
-
- *Robin Dupret*
-
-* Fix rounding errors with `#travel_to` by resetting the usec on any passed time to zero, so we only travel
- with per-second precision, not anything deeper than that.
-
- *DHH*
-
-* Fix DateTime comparison with `DateTime::Infinity` object.
-
- *Rafael Mendonça França*
-
-* Added Object#itself which returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
-
- Event.public_send(state.presence_in([ :trashed, :drafted ]) || :itself).order(:created_at)
-
- *DHH*
-
-* `Object#with_options` executes block in merging option context when
- explicit receiver in not passed.
-
- *Pavel Pravosud*
-
-* Fixed a compatibility issue with the `Oj` gem when cherry-picking the file
- `active_support/core_ext/object/json` without requiring `active_support/json`.
-
- Fixes #16131.
-
- *Godfrey Chan*
-
-* Make `Hash#with_indifferent_access` copy the default proc too.
-
- *arthurnn*, *Xanders*
-
-* Add `String#truncate_words` to truncate a string by a number of words.
-
- *Mohamed Osama*
-
-* Deprecate `capture` and `quietly`.
-
- These methods are not thread safe and may cause issues when used in threaded environments.
- To avoid problems we are deprecating them.
-
- *Tom Meier*
-
-* `DateTime#to_f` now preserves the fractional seconds instead of always
- rounding to `.0`.
-
- Fixes #15994.
-
- *John Paul Ashenfelter*
-
-* Add `Hash#transform_values` to simplify a common pattern where the values of a
- hash must change, but the keys are left the same.
-
- *Sean Griffin*
-
-* Always instrument `ActiveSupport::Cache`.
-
- Since `ActiveSupport::Notifications` only instruments items when there
- are attached subscribers, we don't need to disable instrumentation.
-
- *Peter Wagenet*
-
-* Make the `apply_inflections` method case-insensitive when checking
- whether a word is uncountable or not.
-
- *Robin Dupret*
-
-* Make Dependencies pass a name to NameError error.
-
- *arthurnn*
-
-* Fixed `ActiveSupport::Cache::FileStore` exploding with long paths.
-
- *Adam Panzer*, *Michael Grosser*
-
-* Fixed `ActiveSupport::TimeWithZone#-` so precision is not unnecessarily lost
- when working with objects with a nanosecond component.
-
- `ActiveSupport::TimeWithZone#-` should return the same result as if we were
- using `Time#-`:
-
- Time.now.end_of_day - Time.now.beginning_of_day # => 86399.999999999
-
- Before:
-
- Time.zone.now.end_of_day.nsec # => 999999999
- Time.zone.now.end_of_day - Time.zone.now.beginning_of_day # => 86400.0
-
- After:
-
- Time.zone.now.end_of_day - Time.zone.now.beginning_of_day
- # => 86399.999999999
-
- *Gordon Chan*
-
-* Fixed precision error in NumberHelper when using Rationals.
-
- Before:
-
- ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
- # => "330.00"
-
- After:
-
- ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
- # => "333.33"
-
- See #15379.
-
- *Juanjo Bazán*
-
-* Removed deprecated `Numeric#ago` and friends
-
- Replacements:
-
- 5.ago => 5.seconds.ago
- 5.until => 5.seconds.until
- 5.since => 5.seconds.since
- 5.from_now => 5.seconds.from_now
-
- See #12389 for the history and rationale behind this.
-
- *Godfrey Chan*
-
-* DateTime `advance` now supports partial days.
-
- Before:
-
- DateTime.now.advance(days: 1, hours: 12)
-
- After:
-
- DateTime.now.advance(days: 1.5)
-
- Fixes #12005.
-
- *Shay Davidson*
-
-* `Hash#deep_transform_keys` and `Hash#deep_transform_keys!` now transform hashes
- in nested arrays. This change also applies to `Hash#deep_stringify_keys`,
- `Hash#deep_stringify_keys!`, `Hash#deep_symbolize_keys` and
- `Hash#deep_symbolize_keys!`.
-
- *OZAWA Sakuro*
-
-* Fixed confusing `DelegationError` in `Module#delegate`.
-
- See #15186.
-
- *Vladimir Yarotsky*
-
-* Fixed `ActiveSupport::Subscriber` so that no duplicate subscriber is created
- when a subscriber method is redefined.
-
- *Dennis Schön*
-
-* Remove deprecated string based terminators for `ActiveSupport::Callbacks`.
-
- *Eileen M. Uchitelle*
-
-* Fixed an issue when using
- `ActiveSupport::NumberHelper::NumberToDelimitedConverter` to
- convert a value that is an `ActiveSupport::SafeBuffer` introduced
- in 2da9d67.
-
- See #15064.
-
- *Mark J. Titorenko*
-
-* `TimeZone#parse` defaults the day of the month to '1' if any other date
- components are specified. This is more consistent with the behavior of
- `Time#parse`.
-
- *Ulysse Carion*
-
-* `humanize` strips leading underscores, if any.
-
- Before:
-
- '_id'.humanize # => ""
-
- After:
-
- '_id'.humanize # => "Id"
-
- *Xavier Noria*
-
-* Fixed backward compatibility issues introduced in 326e652.
-
- Empty Hash or Array should not be present in serialization result.
-
- {a: []}.to_query # => ""
- {a: {}}.to_query # => ""
-
- For more info see #14948.
-
- *Bogdan Gusiev*
-
-* Add `Digest::UUID::uuid_v3` and `Digest::UUID::uuid_v5` to support stable
- UUID fixtures on PostgreSQL.
-
- *Roderick van Domburg*
-
-* Fixed `ActiveSupport::Duration#eql?` so that `1.second.eql?(1.second)` is
- true.
-
- This fixes the current situation of:
-
- 1.second.eql?(1.second) # => false
-
- `eql?` also requires that the other object is an `ActiveSupport::Duration`.
- This requirement makes `ActiveSupport::Duration`'s behavior consistent with
- the behavior of Ruby's numeric types:
-
- 1.eql?(1.0) # => false
- 1.0.eql?(1) # => false
-
- 1.second.eql?(1) # => false (was true)
- 1.eql?(1.second) # => false
-
- { 1 => "foo", 1.0 => "bar" }
- # => { 1 => "foo", 1.0 => "bar" }
-
- { 1 => "foo", 1.second => "bar" }
- # now => { 1 => "foo", 1.second => "bar" }
- # was => { 1 => "bar" }
-
- And though the behavior of these hasn't changed, for reference:
-
- 1 == 1.0 # => true
- 1.0 == 1 # => true
-
- 1 == 1.second # => true
- 1.second == 1 # => true
-
- *Emily Dobervich*
-
-* `ActiveSupport::SafeBuffer#prepend` acts like `String#prepend` and modifies
- instance in-place, returning self. `ActiveSupport::SafeBuffer#prepend!` is
- deprecated.
-
- *Pavel Pravosud*
-
-* `HashWithIndifferentAccess` better respects `#to_hash` on objects it
- receives. In particular, `.new`, `#update`, `#merge`, and `#replace` accept
- objects which respond to `#to_hash`, even if those objects are not hashes
- directly.
-
- *Peter Jaros*
-
-* Deprecate `Class#superclass_delegating_accessor`, use `Class#class_attribute` instead.
-
- *Akshay Vishnoi*
-
-* Ensure classes which `include Enumerable` get `#to_json` in addition to
- `#as_json`.
-
- *Sammy Larbi*
-
-* Change the signature of `fetch_multi` to return a hash rather than an
- array. This makes it consistent with the output of `read_multi`.
-
- *Parker Selbert*
-
-* Introduce `Concern#class_methods` as a sleek alternative to clunky
- `module ClassMethods`. Add `Kernel#concern` to define at the toplevel
- without chunky `module Foo; extend ActiveSupport::Concern` boilerplate.
-
- # app/models/concerns/authentication.rb
- concern :Authentication do
- included do
- after_create :generate_private_key
- end
-
- class_methods do
- def authenticate(credentials)
- # ...
- end
- end
-
- def generate_private_key
- # ...
- end
- end
-
- # app/models/user.rb
- class User < ActiveRecord::Base
- include Authentication
- end
-
- *Jeremy Kemper*
-
-Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activesupport/CHANGELOG.md) for previous changes.
+Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activesupport/CHANGELOG.md) for previous changes.
diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec
index 80d1d35888..f86f5133fc 100644
--- a/activesupport/activesupport.gemspec
+++ b/activesupport/activesupport.gemspec
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.summary = 'A toolkit of support libraries and Ruby core extensions extracted from the Rails framework.'
s.description = 'A toolkit of support libraries and Ruby core extensions extracted from the Rails framework. Rich support for multibyte strings, internationalization, time zones, and testing.'
- s.required_ruby_version = '>= 1.9.3'
+ s.required_ruby_version = '>= 2.1.0'
s.license = 'MIT'
diff --git a/activesupport/bin/generate_tables b/activesupport/bin/generate_tables
index f39e89b7d0..71a6b78652 100755
--- a/activesupport/bin/generate_tables
+++ b/activesupport/bin/generate_tables
@@ -55,7 +55,7 @@ module ActiveSupport
codepoint.combining_class = Integer($4)
#codepoint.bidi_class = $5
codepoint.decomp_type = $7
- codepoint.decomp_mapping = ($8=='') ? nil : $8.split.collect { |element| element.hex }
+ codepoint.decomp_mapping = ($8=='') ? nil : $8.split.collect(&:hex)
#codepoint.bidi_mirrored = ($13=='Y') ? true : false
codepoint.uppercase_mapping = ($16=='') ? 0 : $16.hex
codepoint.lowercase_mapping = ($17=='') ? 0 : $17.hex
diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb
index 76ffd23ed1..080e3b5ef7 100644
--- a/activesupport/lib/active_support/core_ext/array/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -92,7 +92,7 @@ class Array
if empty?
'null'
else
- collect { |element| element.id }.join(',')
+ collect(&:id).join(',')
end
else
to_default_s
diff --git a/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb b/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb
index 843c592669..234283e792 100644
--- a/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb
@@ -3,14 +3,13 @@ require 'bigdecimal/util'
class BigDecimal
DEFAULT_STRING_FORMAT = 'F'
- def to_formatted_s(*args)
- if args[0].is_a?(Symbol)
- super
+ alias_method :to_default_s, :to_s
+
+ def to_s(format = nil, options = nil)
+ if format.is_a?(Symbol)
+ to_formatted_s(format, options || {})
else
- format = args[0] || DEFAULT_STRING_FORMAT
- _original_to_s(format)
+ to_default_s(format || DEFAULT_STRING_FORMAT)
end
end
- alias_method :_original_to_s, :to_s
- alias_method :to_s, :to_formatted_s
end
diff --git a/activesupport/lib/active_support/core_ext/hash/keys.rb b/activesupport/lib/active_support/core_ext/hash/keys.rb
index f4105f66b0..9297a59c46 100644
--- a/activesupport/lib/active_support/core_ext/hash/keys.rb
+++ b/activesupport/lib/active_support/core_ext/hash/keys.rb
@@ -31,13 +31,13 @@ class Hash
# hash.stringify_keys
# # => {"name"=>"Rob", "age"=>"28"}
def stringify_keys
- transform_keys{ |key| key.to_s }
+ transform_keys(&:to_s)
end
# Destructively convert all keys to strings. Same as
# +stringify_keys+, but modifies +self+.
def stringify_keys!
- transform_keys!{ |key| key.to_s }
+ transform_keys!(&:to_s)
end
# Returns a new hash with all keys converted to symbols, as long as
@@ -105,14 +105,14 @@ class Hash
# hash.deep_stringify_keys
# # => {"person"=>{"name"=>"Rob", "age"=>"28"}}
def deep_stringify_keys
- deep_transform_keys{ |key| key.to_s }
+ deep_transform_keys(&:to_s)
end
# Destructively convert all keys to strings.
# This includes the keys from the root hash and from all
# nested hashes and arrays.
def deep_stringify_keys!
- deep_transform_keys!{ |key| key.to_s }
+ deep_transform_keys!(&:to_s)
end
# Returns a new hash with all keys converted to symbols, as long as
diff --git a/activesupport/lib/active_support/core_ext/numeric/conversions.rb b/activesupport/lib/active_support/core_ext/numeric/conversions.rb
index 6d3635c69a..0c8ff79237 100644
--- a/activesupport/lib/active_support/core_ext/numeric/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/numeric/conversions.rb
@@ -118,18 +118,28 @@ class Numeric
end
end
- [Float, Fixnum, Bignum, BigDecimal].each do |klass|
- klass.send(:alias_method, :to_default_s, :to_s)
-
- klass.send(:define_method, :to_s) do |*args|
- if args[0].is_a?(Symbol)
- format = args[0]
- options = args[1] || {}
+ [Fixnum, Bignum].each do |klass|
+ klass.class_eval do
+ alias_method :to_default_s, :to_s
+ def to_s(base_or_format = 10, options = nil)
+ if base_or_format.is_a?(Symbol)
+ to_formatted_s(base_or_format, options || {})
+ else
+ to_default_s(base_or_format)
+ end
+ end
+ end
+ end
- self.to_formatted_s(format, options)
+ Float.class_eval do
+ alias_method :to_default_s, :to_s
+ def to_s(*args)
+ if args.empty?
+ to_default_s
else
- to_default_s(*args)
+ to_formatted_s(*args)
end
end
end
+
end
diff --git a/activesupport/lib/active_support/core_ext/object/deep_dup.rb b/activesupport/lib/active_support/core_ext/object/deep_dup.rb
index 2e99f4a1b8..0191d2e973 100644
--- a/activesupport/lib/active_support/core_ext/object/deep_dup.rb
+++ b/activesupport/lib/active_support/core_ext/object/deep_dup.rb
@@ -25,7 +25,7 @@ class Array
# array[1][2] # => nil
# dup[1][2] # => 4
def deep_dup
- map { |it| it.deep_dup }
+ map(&:deep_dup)
end
end
diff --git a/activesupport/lib/active_support/core_ext/object/instance_variables.rb b/activesupport/lib/active_support/core_ext/object/instance_variables.rb
index 755e1c6b16..593a7a4940 100644
--- a/activesupport/lib/active_support/core_ext/object/instance_variables.rb
+++ b/activesupport/lib/active_support/core_ext/object/instance_variables.rb
@@ -23,6 +23,6 @@ class Object
#
# C.new(0, 1).instance_variable_names # => ["@y", "@x"]
def instance_variable_names
- instance_variables.map { |var| var.to_s }
+ instance_variables.map(&:to_s)
end
end
diff --git a/activesupport/lib/active_support/core_ext/object/to_query.rb b/activesupport/lib/active_support/core_ext/object/to_query.rb
index ccd568bbf5..ec5ace4e16 100644
--- a/activesupport/lib/active_support/core_ext/object/to_query.rb
+++ b/activesupport/lib/active_support/core_ext/object/to_query.rb
@@ -38,7 +38,7 @@ class Array
# Calls <tt>to_param</tt> on all its elements and joins the result with
# slashes. This is used by <tt>url_for</tt> in Action Pack.
def to_param
- collect { |e| e.to_param }.join '/'
+ collect(&:to_param).join '/'
end
# Converts an array into a string suitable for use as a URL query string,
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 65a370dd30..ff8c0fd310 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -742,7 +742,7 @@ module ActiveSupport #:nodoc:
protected
def log_call(*args)
if log_activity?
- arg_str = args.collect { |arg| arg.inspect } * ', '
+ arg_str = args.collect(&:inspect) * ', '
/in `([a-z_\?\!]+)'/ =~ caller(1).first
selector = $1 || '<unknown>'
log "called #{selector}(#{arg_str})"
diff --git a/activesupport/lib/active_support/gem_version.rb b/activesupport/lib/active_support/gem_version.rb
index bc7933e38b..7068f09d87 100644
--- a/activesupport/lib/active_support/gem_version.rb
+++ b/activesupport/lib/active_support/gem_version.rb
@@ -5,10 +5,10 @@ module ActiveSupport
end
module VERSION
- MAJOR = 4
- MINOR = 2
+ MAJOR = 5
+ MINOR = 0
TINY = 0
- PRE = "beta4"
+ PRE = "alpha"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end
diff --git a/activesupport/lib/active_support/number_helper/number_to_human_converter.rb b/activesupport/lib/active_support/number_helper/number_to_human_converter.rb
index 9a3dc526ae..6940beb318 100644
--- a/activesupport/lib/active_support/number_helper/number_to_human_converter.rb
+++ b/activesupport/lib/active_support/number_helper/number_to_human_converter.rb
@@ -59,7 +59,7 @@ module ActiveSupport
translate_in_locale("human.decimal_units.units", raise: true)
else
raise ArgumentError, ":units must be a Hash or String translation scope."
- end.keys.map { |e_name| INVERTED_DECIMAL_UNITS[e_name] }.sort_by { |e| -e }
+ end.keys.map { |e_name| INVERTED_DECIMAL_UNITS[e_name] }.sort_by(&:-@)
end
end
end
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb
index 11cca82995..8b649c193f 100644
--- a/activesupport/lib/active_support/testing/assertions.rb
+++ b/activesupport/lib/active_support/testing/assertions.rb
@@ -66,7 +66,7 @@ module ActiveSupport
exps = expressions.map { |e|
e.respond_to?(:call) ? e : lambda { eval(e, block.binding) }
}
- before = exps.map { |e| e.call }
+ before = exps.map(&:call)
yield
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index 55533a5d40..fd05a5459c 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -237,7 +237,7 @@ module ActiveSupport
case arg
when String
begin
- @lazy_zones_map[arg] ||= create(arg).tap { |tz| tz.utc_offset }
+ @lazy_zones_map[arg] ||= create(arg).tap(&:utc_offset)
rescue TZInfo::InvalidTimezoneIdentifier
nil
end
diff --git a/activesupport/lib/active_support/xml_mini/jdom.rb b/activesupport/lib/active_support/xml_mini/jdom.rb
index 27c64c4dca..f303daa1a7 100644
--- a/activesupport/lib/active_support/xml_mini/jdom.rb
+++ b/activesupport/lib/active_support/xml_mini/jdom.rb
@@ -141,7 +141,7 @@ module ActiveSupport
(0...attributes.length).each do |i|
attribute_hash[CONTENT_KEY] ||= ''
attribute_hash[attributes.item(i).name] = attributes.item(i).value
- end
+ end
attribute_hash
end
diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb
index 6fcf6e8743..346dc3d208 100644
--- a/activesupport/test/core_ext/enumerable_test.rb
+++ b/activesupport/test/core_ext/enumerable_test.rb
@@ -71,14 +71,14 @@ class EnumerableTests < ActiveSupport::TestCase
def test_index_by
payments = GenericEnumerable.new([ Payment.new(5), Payment.new(15), Payment.new(10) ])
assert_equal({ 5 => Payment.new(5), 15 => Payment.new(15), 10 => Payment.new(10) },
- payments.index_by { |p| p.price })
+ payments.index_by(&:price))
assert_equal Enumerator, payments.index_by.class
if Enumerator.method_defined? :size
assert_equal nil, payments.index_by.size
assert_equal 42, (1..42).index_by.size
end
assert_equal({ 5 => Payment.new(5), 15 => Payment.new(15), 10 => Payment.new(10) },
- payments.index_by.each { |p| p.price })
+ payments.index_by.each(&:price))
end
def test_many
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index 5e9fdfd872..3d2f50ce49 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -365,7 +365,7 @@ class HashExtTest < ActiveSupport::TestCase
:member? => true }
hashes.each do |name, hash|
- method_map.sort_by { |m| m.to_s }.each do |meth, expected|
+ method_map.sort_by(&:to_s).each do |meth, expected|
assert_equal(expected, hash.__send__(meth, 'a'),
"Calling #{name}.#{meth} 'a'")
assert_equal(expected, hash.__send__(meth, :a),
diff --git a/activesupport/test/core_ext/object/try_test.rb b/activesupport/test/core_ext/object/try_test.rb
index efc6beaf02..89438675c1 100644
--- a/activesupport/test/core_ext/object/try_test.rb
+++ b/activesupport/test/core_ext/object/try_test.rb
@@ -52,11 +52,11 @@ class ObjectTryTest < ActiveSupport::TestCase
end
def test_try_only_block
- assert_equal @string.reverse, @string.try { |s| s.reverse }
+ assert_equal @string.reverse, @string.try(&:reverse)
end
def test_try_only_block_bang
- assert_equal @string.reverse, @string.try! { |s| s.reverse }
+ assert_equal @string.reverse, @string.try!(&:reverse)
end
def test_try_only_block_nil
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index e32c178951..0af207fae9 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -281,15 +281,11 @@ class StringInflectionsTest < ActiveSupport::TestCase
end
def test_constantize
- run_constantize_tests_on do |string|
- string.constantize
- end
+ run_constantize_tests_on(&:constantize)
end
def test_safe_constantize
- run_safe_constantize_tests_on do |string|
- string.safe_constantize
- end
+ run_safe_constantize_tests_on(&:safe_constantize)
end
end
diff --git a/activesupport/test/multibyte_chars_test.rb b/activesupport/test/multibyte_chars_test.rb
index feca013675..94748dd991 100644
--- a/activesupport/test/multibyte_chars_test.rb
+++ b/activesupport/test/multibyte_chars_test.rb
@@ -182,7 +182,7 @@ class MultibyteCharsUTF8BehaviourTest < ActiveSupport::TestCase
end
def test_sortability
- words = %w(builder armor zebra).sort_by { |s| s.mb_chars }
+ words = %w(builder armor zebra).sort_by(&:mb_chars)
assert_equal %w(armor builder zebra), words
end
diff --git a/activesupport/test/multibyte_conformance_test.rb b/activesupport/test/multibyte_conformance_test.rb
index aba81b8248..f7bd21c8ab 100644
--- a/activesupport/test/multibyte_conformance_test.rb
+++ b/activesupport/test/multibyte_conformance_test.rb
@@ -115,7 +115,7 @@ class MultibyteConformanceTest < ActiveSupport::TestCase
next if (line.empty? || line =~ /^\#/)
cols, comment = line.split("#")
- cols = cols.split(";").map{|e| e.strip}.reject{|e| e.empty? }
+ cols = cols.split(";").map(&:strip).reject(&:empty?)
next unless cols.length == 5
# codepoints are in hex in the test suite, pack wants them as integers
diff --git a/activesupport/test/rescuable_test.rb b/activesupport/test/rescuable_test.rb
index ec9d231125..b8af888f7c 100644
--- a/activesupport/test/rescuable_test.rb
+++ b/activesupport/test/rescuable_test.rb
@@ -93,13 +93,13 @@ class RescuableTest < ActiveSupport::TestCase
def test_rescues_defined_later_are_added_at_end_of_the_rescue_handlers_array
expected = ["WraithAttack", "WraithAttack", "NuclearExplosion", "MadRonon"]
- result = @stargate.send(:rescue_handlers).collect {|e| e.first}
+ result = @stargate.send(:rescue_handlers).collect(&:first)
assert_equal expected, result
end
def test_children_should_inherit_rescue_definitions_from_parents_and_child_rescue_should_be_appended
expected = ["WraithAttack", "WraithAttack", "NuclearExplosion", "MadRonon", "CoolError"]
- result = @cool_stargate.send(:rescue_handlers).collect {|e| e.first}
+ result = @cool_stargate.send(:rescue_handlers).collect(&:first)
assert_equal expected, result
end
end
diff --git a/ci/travis.rb b/ci/travis.rb
index a1920a7a1f..b62f90a59e 100755
--- a/ci/travis.rb
+++ b/ci/travis.rb
@@ -140,6 +140,6 @@ if failures.empty?
else
puts
puts "Rails build FAILED"
- puts "Failed components: #{failures.map { |component| component.first }.join(', ')}"
+ puts "Failed components: #{failures.map(&:first).join(', ')}"
exit(false)
end
diff --git a/guides/CHANGELOG.md b/guides/CHANGELOG.md
index 2770fc73e7..afaa404ac1 100644
--- a/guides/CHANGELOG.md
+++ b/guides/CHANGELOG.md
@@ -1,27 +1 @@
-* Change Posts to Articles in Getting Started sample application in order to
-better align with the actual guides.
-
- *John Kelly Ferguson*
-
-* Update all Rails 4.1.0 references to 4.1.1 within the guides and code.
-
- *John Kelly Ferguson*
-
-* Split up rows in the Explain Queries table of the ActiveRecord Querying section
-in order to improve readability.
-
- *John Kelly Ferguson*
-
-* Change all non-HTTP method 'post' references to 'article'.
-
- *John Kelly Ferguson*
-
-* Updates the maintenance policy to match the latest versions of Rails
-
- *Matias Korhonen*
-
-* Switched the order of `Applying a default scope` and `Merging of scopes` subsections so default scopes are introduced first.
-
- *Alex Riabov*
-
-Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/guides/CHANGELOG.md) for previous changes.
+Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/guides/CHANGELOG.md) for previous changes.
diff --git a/guides/rails_guides/kindle.rb b/guides/rails_guides/kindle.rb
index 09eecd5634..32926622e3 100644
--- a/guides/rails_guides/kindle.rb
+++ b/guides/rails_guides/kindle.rb
@@ -70,7 +70,7 @@ module Kindle
File.open("sections/%03d/_section.txt" % section_idx, 'w') {|f| f.puts title}
doc.xpath("//h3[@id]").each_with_index do |h3,item_idx|
subsection = h3.inner_text
- content = h3.xpath("./following-sibling::*").take_while {|x| x.name != "h3"}.map {|x| x.to_html}
+ content = h3.xpath("./following-sibling::*").take_while {|x| x.name != "h3"}.map(&:to_html)
item = Nokogiri::HTML(h3.to_html + content.join("\n"))
item_path = "sections/%03d/%03d.html" % [section_idx, item_idx]
add_head_section(item, subsection)
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md
index 616b813817..7b11092f3d 100644
--- a/guides/source/active_support_core_extensions.md
+++ b/guides/source/active_support_core_extensions.md
@@ -1447,7 +1447,7 @@ Returns the substring of the string starting at position `position`:
"hello".from(0) # => "hello"
"hello".from(2) # => "llo"
"hello".from(-2) # => "lo"
-"hello".from(10) # => "" if < 1.9, nil in 1.9
+"hello".from(10) # => nil
```
NOTE: Defined in `active_support/core_ext/string/access.rb`.
diff --git a/guides/source/i18n.md b/guides/source/i18n.md
index f6cbc1823a..75b5275245 100644
--- a/guides/source/i18n.md
+++ b/guides/source/i18n.md
@@ -626,7 +626,7 @@ entry[count == 1 ? 0 : 1]
I.e. the translation denoted as `:one` is regarded as singular, the other is used as plural (including the count being zero).
-If the lookup for the key does not return a Hash suitable for pluralization, an `18n::InvalidPluralizationData` exception is raised.
+If the lookup for the key does not return a Hash suitable for pluralization, an `I18n::InvalidPluralizationData` exception is raised.
### Setting and Passing a Locale
diff --git a/rails.gemspec b/rails.gemspec
index 9969748a09..be83304e2b 100644
--- a/rails.gemspec
+++ b/rails.gemspec
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.summary = 'Full-stack web application framework.'
s.description = 'Ruby on Rails is a full-stack web framework optimized for programmer happiness and sustainable productivity. It encourages beautiful code by favoring convention over configuration.'
- s.required_ruby_version = '>= 1.9.3'
+ s.required_ruby_version = '>= 2.1.0'
s.required_rubygems_version = '>= 1.8.11'
s.license = 'MIT'
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index ff6dcac465..cd7f3b1e2f 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,208 +1 @@
-* Generated migrations add the appropriate foreign key constraints to
- references.
-
- *Derek Prior*
-
-* Deprecate different default for `log_level` in production.
-
- *Godfrey Chan*, *Matthew Draper*
-
-* Generated `.gitignore` excludes the whole `log/` directory, not only
- `*.log` files.
-
- *ShunsukeAida*
-
-* `Rails::Paths::Path.unshift` now has the same interface as `Array.unshift`.
-
- *Igor Kapkov*
-
-* Make `rake test` run all tests in test folder.
-
- Deprecate `rake test:all` and replace `rake test:all:db` with `rake test:db`
-
- *David Geukers*
-
-* `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*
-
-* Remove `--skip-action-view` option from `Rails::Generators::AppBase`.
-
- Fixes #17023.
-
- *Dan Olson*
-
-* Specify dummy app's db migrate path in plugin's test_helper.rb.
-
- Fixes #16877.
-
- *Yukio Mizuta*
-
-* Inject `Rack::Lock` if `config.eager_load` is false.
-
- Fixes #15089.
-
- *Xavier Noria*
-
-* Change the path of dummy app location in plugin's test_helper.rb for cases
- you specify dummy_path option.
-
- *Yukio Mizuta*
-
-* Fix a bug in the `gem` method for Rails templates when non-String options
- are used.
-
- Fixes #16709.
-
- *Yves Senn*
-
-* The [web-console](https://github.com/rails/web-console) gem is now
- installed by default for new applications. It can help you debug
- development exceptions by spawning an interactive console in its cause
- binding.
-
- *Ryan Dao*, *Genadi Samokovarov*, *Guillermo Iguaran*
-
-* Add a `required` option to the model generator for associations
-
- *Sean Griffin*
-
-* Add `after_bundle` callbacks in Rails templates. Useful for allowing the
- generated binstubs to be added to version control.
-
- Fixes #16292.
-
- *Stefan Kanev*
-
-* Pull in the custom configuration concept from dhh/custom_configuration, which allows you to
- configure your own code through the Rails configuration object with custom configuration:
-
- # config/environments/production.rb
- config.x.payment_processing.schedule = :daily
- config.x.payment_processing.retries = 3
- config.x.super_debugger = true
-
- These configuration points are then available through the configuration object:
-
- Rails.configuration.x.payment_processing.schedule # => :daily
- Rails.configuration.x.payment_processing.retries # => 3
- Rails.configuration.x.super_debugger # => true
-
- *DHH*
-
-* Scaffold generator `_form` partial adds `class="field"` for password
- confirmation fields.
-
- *noinkling*
-
-* Add `Rails::Application.config_for` to load a configuration for the current
- environment.
-
- # config/exception_notification.yml:
- production:
- url: http://127.0.0.1:8080
- namespace: my_app_production
- development:
- url: http://localhost:3001
- namespace: my_app_development
-
- # config/production.rb
- Rails.application.configure do
- config.middleware.use ExceptionNotifier, config_for(:exception_notification)
- end
-
- *Rafael Mendonça França*, *DHH*
-
-* Deprecate `Rails::Rack::LogTailer` without replacement.
-
- *Rafael Mendonça França*
-
-* Add `--skip-turbolinks` option to the app generator.
-
- *Rafael Mendonça França*
-
-* Invalid `bin/rails generate` commands will now show spelling suggestions.
-
- *Richard Schneeman*
-
-* Add `bin/setup` script to bootstrap an application.
-
- *Yves Senn*
-
-* Replace double quotes with single quotes while adding an entry into Gemfile.
-
- *Alexander Belaev*
-
-* Default `config.assets.digest` to `true` in development.
-
- *Dan Kang*
-
-* Load database configuration from the first `database.yml` available in paths.
-
- *Pier-Olivier Thibault*
-
-* Reading name and email from git for plugin gemspec.
-
- Fixes #9589.
-
- *Arun Agrawal*, *Abd ar-Rahman Hamidi*, *Roman Shmatov*
-
-* Fix `console` and `generators` blocks defined at different environments.
-
- Fixes #14748.
-
- *Rafael Mendonça França*
-
-* Move configuration of asset precompile list and version to an initializer.
-
- *Matthew Draper*
-
-* Remove sqlite3 lines from `.gitignore` if the application is not using sqlite3.
-
- *Dmitrii Golub*
-
-* Add public API to register new extensions for `rake notes`.
-
- Example:
-
- config.annotations.register_extensions("scss", "sass") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
-
- *Roberto Miranda*
-
-* Removed unnecessary `rails application` command.
-
- *Arun Agrawal*
-
-* Make the `rails:template` rake task load the application's initializers.
-
- Fixes #12133.
-
- *Robin Dupret*
-
-* Introduce `Rails.gem_version` as a convenience method to return
- `Gem::Version.new(Rails.version)`, suggesting a more reliable way to perform
- version comparison.
-
- Example:
-
- Rails.version #=> "4.1.2"
- Rails.gem_version #=> #<Gem::Version "4.1.2">
-
- Rails.version > "4.1.10" #=> false
- Rails.gem_version > Gem::Version.new("4.1.10") #=> true
- Gem::Requirement.new("~> 4.1.2") =~ Rails.gem_version #=> true
-
- *Prem Sichanugrist*
-
-* Avoid namespacing routes inside engines.
-
- Mountable engines are namespaced by default so the generated routes
- were too while they should not.
-
- Fixes #14079.
-
- *Yves Senn*, *Carlos Antonio da Silva*, *Robin Dupret*
-
-Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/railties/CHANGELOG.md) for previous changes.
+Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/railties/CHANGELOG.md) for previous changes.
diff --git a/railties/lib/rails/application/routes_reloader.rb b/railties/lib/rails/application/routes_reloader.rb
index 737977adf9..cf0a4e128f 100644
--- a/railties/lib/rails/application/routes_reloader.rb
+++ b/railties/lib/rails/application/routes_reloader.rb
@@ -41,9 +41,7 @@ module Rails
end
def finalize!
- route_sets.each do |routes|
- routes.finalize!
- end
+ route_sets.each(&:finalize!)
end
def revert
diff --git a/railties/lib/rails/commands/plugin.rb b/railties/lib/rails/commands/plugin.rb
index 95bbdd4cdf..52d8966ead 100644
--- a/railties/lib/rails/commands/plugin.rb
+++ b/railties/lib/rails/commands/plugin.rb
@@ -11,7 +11,7 @@ else
end
if File.exist?(railsrc)
extra_args_string = File.read(railsrc)
- extra_args = extra_args_string.split(/\n+/).flat_map {|l| l.split}
+ extra_args = extra_args_string.split(/\n+/).flat_map(&:split)
puts "Using #{extra_args.join(" ")} from #{railsrc}"
ARGV.insert(1, *extra_args)
end
diff --git a/railties/lib/rails/gem_version.rb b/railties/lib/rails/gem_version.rb
index 8abed99f2c..7d74b1bfe5 100644
--- a/railties/lib/rails/gem_version.rb
+++ b/railties/lib/rails/gem_version.rb
@@ -5,10 +5,10 @@ module Rails
end
module VERSION
- MAJOR = 4
- MINOR = 2
+ MAJOR = 5
+ MINOR = 0
TINY = 0
- PRE = "beta4"
+ PRE = "alpha"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index bf2390cb7e..e25c364178 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -153,7 +153,7 @@ module Rails
def self.invoke(namespace, args=ARGV, config={})
names = namespace.to_s.split(':')
if klass = find_by_namespace(names.pop, names.any? && names.join(':'))
- args << "--help" if args.empty? && klass.arguments.any? { |a| a.required? }
+ args << "--help" if args.empty? && klass.arguments.any?(&:required?)
klass.start(args, config)
else
options = sorted_groups.map(&:last).flatten
@@ -226,7 +226,7 @@ module Rails
def self.public_namespaces
lookup!
- subclasses.map { |k| k.namespace }
+ subclasses.map(&:namespace)
end
def self.print_generators
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb
index ffdb314612..5373121835 100644
--- a/railties/lib/rails/generators/actions.rb
+++ b/railties/lib/rails/generators/actions.rb
@@ -189,7 +189,7 @@ module Rails
# generate(:authenticated, "user session")
def generate(what, *args)
log :generate, what
- argument = args.flat_map {|arg| arg.to_s }.join(" ")
+ argument = args.flat_map(&:to_s).join(" ")
in_root { run_ruby_script("bin/rails generate #{what} #{argument}", verbose: false) }
end
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 0823b0cc46..f5ae600bd8 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -240,8 +240,7 @@ module Rails
gems << GemfileEntry.github('sass-rails', 'rails/sass-rails',
'Use SCSS for stylesheets')
else
- gems << GemfileEntry.version('sass-rails',
- '~> 5.0.0.beta1',
+ gems << GemfileEntry.version('sass-rails', '~> 4.0',
'Use SCSS for stylesheets')
end
diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb
index 9af6435f23..813b8b629e 100644
--- a/railties/lib/rails/generators/base.rb
+++ b/railties/lib/rails/generators/base.rb
@@ -273,7 +273,7 @@ module Rails
# Use Rails default banner.
def self.banner
- "rails generate #{namespace.sub(/^rails:/,'')} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]".gsub(/\s+/, ' ')
+ "rails generate #{namespace.sub(/^rails:/,'')} #{self.arguments.map(&:usage).join(' ')} [options]".gsub(/\s+/, ' ')
end
# Sets the base_name taking into account the current class namespace.
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb
index b7da44ca2d..397e1e73f1 100644
--- a/railties/lib/rails/generators/named_base.rb
+++ b/railties/lib/rails/generators/named_base.rb
@@ -99,7 +99,7 @@ module Rails
end
def class_name
- (class_path + [file_name]).map!{ |m| m.camelize }.join('::')
+ (class_path + [file_name]).map!(&:camelize).join('::')
end
def human_name
@@ -156,7 +156,7 @@ module Rails
def assign_names!(name) #:nodoc:
@class_path = name.include?('/') ? name.split('/') : name.split('::')
- @class_path.map! { |m| m.underscore }
+ @class_path.map!(&:underscore)
@file_name = @class_path.pop
end
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index 9110c129d1..f8a8ae90d9 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -260,9 +260,7 @@ module Rails
public_task :generate_spring_binstubs
def run_after_bundle_callbacks
- @after_bundle_callbacks.each do |callback|
- callback.call
- end
+ @after_bundle_callbacks.each(&:call)
end
protected
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
index 32756eb88b..03a3568fbe 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
@@ -31,7 +31,7 @@ Rails.application.configure do
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
- # Randomize the order test cases are executed
+ # Randomize the order test cases are executed.
config.active_support.test_order = :random
# Print deprecation notices to the stderr.
diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb
index 4669935156..3f84d76ae0 100644
--- a/railties/lib/rails/generators/resource_helpers.rb
+++ b/railties/lib/rails/generators/resource_helpers.rb
@@ -39,7 +39,7 @@ module Rails
def assign_controller_names!(name)
@controller_name = name
@controller_class_path = name.include?('/') ? name.split('/') : name.split('::')
- @controller_class_path.map! { |m| m.underscore }
+ @controller_class_path.map!(&:underscore)
@controller_file_name = @controller_class_path.pop
end
@@ -48,7 +48,7 @@ module Rails
end
def controller_class_name
- (controller_class_path + [controller_file_name]).map!{ |m| m.camelize }.join('::')
+ (controller_class_path + [controller_file_name]).map!(&:camelize).join('::')
end
def controller_i18n_scope
diff --git a/railties/lib/rails/info.rb b/railties/lib/rails/info.rb
index 94ede76932..5909446b66 100644
--- a/railties/lib/rails/info.rb
+++ b/railties/lib/rails/info.rb
@@ -8,7 +8,7 @@ module Rails
mattr_accessor :properties
class << (@@properties = [])
def names
- map {|val| val.first }
+ map(&:first)
end
def value_for(property_name)
@@ -26,7 +26,7 @@ module Rails
end
def to_s
- column_width = properties.names.map {|name| name.length}.max
+ column_width = properties.names.map(&:length).max
info = properties.map do |name, value|
value = value.join(", ") if value.is_a?(Array)
"%-#{column_width}s %s" % [name, value]
diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb
index d11804af17..5458036219 100644
--- a/railties/lib/rails/paths.rb
+++ b/railties/lib/rails/paths.rb
@@ -77,23 +77,23 @@ module Rails
end
def all_paths
- values.tap { |v| v.uniq! }
+ values.tap(&:uniq!)
end
def autoload_once
- filter_by { |p| p.autoload_once? }
+ filter_by(&:autoload_once?)
end
def eager_load
- filter_by { |p| p.eager_load? }
+ filter_by(&:eager_load?)
end
def autoload_paths
- filter_by { |p| p.autoload? }
+ filter_by(&:autoload?)
end
def load_paths
- filter_by { |p| p.load_path? }
+ filter_by(&:load_path?)
end
private
diff --git a/railties/lib/rails/ruby_version_check.rb b/railties/lib/rails/ruby_version_check.rb
index df74643a59..edfe5cb786 100644
--- a/railties/lib/rails/ruby_version_check.rb
+++ b/railties/lib/rails/ruby_version_check.rb
@@ -1,13 +1,13 @@
-if RUBY_VERSION < '1.9.3'
+if RUBY_VERSION < '2.1.0'
desc = defined?(RUBY_DESCRIPTION) ? RUBY_DESCRIPTION : "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
abort <<-end_message
- Rails 4 prefers to run on Ruby 2.1 or newer.
+ Rails 5 requires to run on Ruby 2.1 or newer.
You're running
#{desc}
- Please upgrade to Ruby 1.9.3 or newer to continue.
+ Please upgrade to Ruby 2.1.0 or newer to continue.
end_message
end
diff --git a/railties/railties.gemspec b/railties/railties.gemspec
index 56b8736800..09afcdec04 100644
--- a/railties/railties.gemspec
+++ b/railties/railties.gemspec
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.summary = 'Tools for creating, working with, and running Rails applications.'
s.description = 'Rails internals: application bootup, plugins, generators, and rake tasks.'
- s.required_ruby_version = '>= 1.9.3'
+ s.required_ruby_version = '>= 2.1.0'
s.license = 'MIT'
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb
index 6239af2066..260ee0eda9 100644
--- a/railties/test/railties/engine_test.rb
+++ b/railties/test/railties/engine_test.rb
@@ -518,7 +518,7 @@ YAML
def call(env)
response = @app.call(env)
- response[2].each { |b| b.upcase! }
+ response[2].each(&:upcase!)
response
end
end
diff --git a/version.rb b/version.rb
index 8abed99f2c..7d74b1bfe5 100644
--- a/version.rb
+++ b/version.rb
@@ -5,10 +5,10 @@ module Rails
end
module VERSION
- MAJOR = 4
- MINOR = 2
+ MAJOR = 5
+ MINOR = 0
TINY = 0
- PRE = "beta4"
+ PRE = "alpha"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end