Skip to content

Commit

Permalink
Rails 6 requires Ruby 2.4.1+
Browse files Browse the repository at this point in the history
Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug.

References #32028
  • Loading branch information
jeremy committed Feb 17, 2018
1 parent 33886e2 commit d4eb0dc
Show file tree
Hide file tree
Showing 52 changed files with 133 additions and 253 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.3
TargetRubyVersion: 2.4
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Expand Down
23 changes: 8 additions & 15 deletions .travis.yml
Expand Up @@ -60,28 +60,21 @@ env:
- "GEM=ac:integration"

rvm:
- 2.3.6
- 2.4.3
- 2.5.0
- 2.4
- 2.5
- ruby-head

matrix:
include:
- rvm: 2.5.0
- rvm: 2.5
env: "GEM=av:ujs"
- rvm: 2.3.6
- rvm: 2.4
env: "GEM=aj:integration"
services:
- memcached
- redis-server
- rabbitmq
- rvm: 2.4.3
env: "GEM=aj:integration"
services:
- memcached
- redis-server
- rabbitmq
- rvm: 2.5.0
- rvm: 2.5
env: "GEM=aj:integration"
services:
- memcached
Expand All @@ -93,15 +86,15 @@ matrix:
- memcached
- redis-server
- rabbitmq
- rvm: 2.3.6
- rvm: 2.5
env:
- "GEM=ar:mysql2 MYSQL=mariadb"
addons:
mariadb: 10.2
- rvm: 2.3.6
- rvm: 2.5
env:
- "GEM=ar:sqlite3_mem"
- rvm: 2.3.6
- rvm: 2.5
env:
- "GEM=ar:postgresql POSTGRES=9.2"
addons:
Expand Down
5 changes: 5 additions & 0 deletions actioncable/CHANGELOG.md
@@ -1,3 +1,8 @@
## Rails 6.0.0.alpha (Unreleased) ##

* Rails 6 requires Ruby 2.4.1 or newer.

*Jeremy Daer*


Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/actioncable/CHANGELOG.md) for previous changes.
2 changes: 1 addition & 1 deletion actioncable/actioncable.gemspec
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.summary = "WebSocket framework for Rails."
s.description = "Structure many real-time application concerns into channels over a single WebSocket connection."

s.required_ruby_version = ">= 2.3.0"
s.required_ruby_version = ">= 2.4.1"

s.license = "MIT"

Expand Down
5 changes: 5 additions & 0 deletions actionmailer/CHANGELOG.md
@@ -1,3 +1,8 @@
## Rails 6.0.0.alpha (Unreleased) ##

* Rails 6 requires Ruby 2.4.1 or newer.

*Jeremy Daer*


Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/actionmailer/CHANGELOG.md) for previous changes.
2 changes: 1 addition & 1 deletion actionmailer/actionmailer.gemspec
Expand Up @@ -9,7 +9,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 = ">= 2.3.0"
s.required_ruby_version = ">= 2.4.1"

s.license = "MIT"

Expand Down
6 changes: 6 additions & 0 deletions actionpack/CHANGELOG.md
@@ -1,3 +1,9 @@
## Rails 6.0.0.alpha (Unreleased) ##

* Rails 6 requires Ruby 2.4.1 or newer.

*Jeremy Daer*

* Add alias method `to_hash` to `to_h` for `cookies`.
Add alias method `to_h` to `to_hash` for `session`.

Expand Down
2 changes: 1 addition & 1 deletion actionpack/actionpack.gemspec
Expand Up @@ -9,7 +9,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 = ">= 2.3.0"
s.required_ruby_version = ">= 2.4.1"

s.license = "MIT"

Expand Down
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require "active_support/core_ext/hash/indifferent_access"
require "active_support/core_ext/hash/transform_values"
require "active_support/core_ext/array/wrap"
require "active_support/core_ext/string/filters"
require "active_support/core_ext/object/to_query"
Expand Down
1 change: 0 additions & 1 deletion actionpack/test/controller/parameters/accessors_test.rb
Expand Up @@ -2,7 +2,6 @@

require "abstract_unit"
require "action_controller/metal/strong_parameters"
require "active_support/core_ext/hash/transform_values"

class ParametersAccessorsTest < ActiveSupport::TestCase
setup do
Expand Down
1 change: 0 additions & 1 deletion actionpack/test/controller/parameters/mutators_test.rb
Expand Up @@ -2,7 +2,6 @@

require "abstract_unit"
require "action_controller/metal/strong_parameters"
require "active_support/core_ext/hash/transform_values"

class ParametersMutatorsTest < ActiveSupport::TestCase
setup do
Expand Down
5 changes: 5 additions & 0 deletions actionview/CHANGELOG.md
@@ -1,3 +1,8 @@
## Rails 6.0.0.alpha (Unreleased) ##

* Rails 6 requires Ruby 2.4.1 or newer.

*Jeremy Daer*


Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/actionview/CHANGELOG.md) for previous changes.
2 changes: 1 addition & 1 deletion actionview/actionview.gemspec
Expand Up @@ -9,7 +9,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 = ">= 2.3.0"
s.required_ruby_version = ">= 2.4.1"

s.license = "MIT"

Expand Down
6 changes: 2 additions & 4 deletions actionview/test/template/date_helper_test.rb
Expand Up @@ -144,15 +144,13 @@ def test_distance_in_words_doesnt_use_the_quotient_operator
rubinius_skip "Date is written in Ruby and relies on Fixnum#/"
jruby_skip "Date is written in Ruby and relies on Fixnum#/"

klass = RUBY_VERSION > "2.4" ? Integer : Fixnum

# Make sure that we avoid {Integer,Fixnum}#/ (redefined by mathn)

This comment has been minimized.

Copy link
@lucascaton

lucascaton Feb 28, 2018

Contributor

@jeremy shouldn't this line be removed as well? πŸ™‚

This comment has been minimized.

Copy link
@jeremy

jeremy Feb 28, 2018

Author Member

Sure, we could say just Integer#/ πŸ‘

This comment has been minimized.

Copy link
@bogdanvlviv

bogdanvlviv Feb 28, 2018

Contributor

I think we should look at git grep "Fixnum\|Bignum" and apply some changes where it is needed

klass.send :private, :/
Integer.send :private, :/

from = Time.utc(2004, 6, 6, 21, 45, 0)
assert_distance_of_time_in_words(from)
ensure
klass.send :public, :/
Integer.send :public, :/
end

def test_time_ago_in_words_passes_include_seconds
Expand Down
6 changes: 6 additions & 0 deletions activejob/CHANGELOG.md
@@ -1,3 +1,9 @@
## Rails 6.0.0.alpha (Unreleased) ##

* Rails 6 requires Ruby 2.4.1 or newer.

*Jeremy Daer*

* Add support to define custom argument serializers.

*Evgenii Pecherkin*, *Rafael Mendonça França*
Expand Down
2 changes: 1 addition & 1 deletion activejob/activejob.gemspec
Expand Up @@ -9,7 +9,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 = ">= 2.3.0"
s.required_ruby_version = ">= 2.4.1"

s.license = "MIT"

Expand Down
5 changes: 2 additions & 3 deletions activejob/lib/active_job/arguments.rb
Expand Up @@ -14,8 +14,8 @@ def initialize #:nodoc:
end

# Raised when an unsupported argument type is set as a job argument. We
# currently support NilClass, Integer, Fixnum, Float, String, TrueClass, FalseClass,
# Bignum, BigDecimal, and objects that can be represented as GlobalIDs (ex: Active Record).
# currently support NilClass, Integer, Float, String, TrueClass, FalseClass,
# BigDecimal, and objects that can be represented as GlobalIDs (ex: Active Record).
# Raised if you set the key for a Hash something else than a string or
# a symbol. Also raised when trying to serialize an object which can't be
# identified with a Global ID - such as an unpersisted Active Record model.
Expand All @@ -25,7 +25,6 @@ module Arguments
extend self
# :nodoc:
TYPE_WHITELIST = [ NilClass, String, Integer, Float, BigDecimal, TrueClass, FalseClass ]
TYPE_WHITELIST.push(Fixnum, Bignum) unless 1.class == Integer

# Serializes a set of arguments. Whitelisted types are returned
# as-is. Arrays/Hashes are serialized element by element.
Expand Down
1 change: 0 additions & 1 deletion activejob/lib/active_job/logging.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/hash/transform_values"
require "active_support/core_ext/string/filters"
require "active_support/tagged_logging"
require "active_support/logger"
Expand Down
5 changes: 5 additions & 0 deletions activemodel/CHANGELOG.md
@@ -1,3 +1,8 @@
## Rails 6.0.0.alpha (Unreleased) ##

* Rails 6 requires Ruby 2.4.1 or newer.

*Jeremy Daer*


Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activemodel/CHANGELOG.md) for previous changes.
2 changes: 1 addition & 1 deletion activemodel/activemodel.gemspec
Expand Up @@ -9,7 +9,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 = ">= 2.3.0"
s.required_ruby_version = ">= 2.4.1"

s.license = "MIT"

Expand Down
5 changes: 5 additions & 0 deletions activerecord/CHANGELOG.md
@@ -1,4 +1,9 @@
## Rails 6.0.0.alpha (Unreleased) ##

* Rails 6 requires Ruby 2.4.1 or newer.

*Jeremy Daer*

* Deprecate `update_attributes`/`!` in favor of `update`/`!`.

*Eddie Lebow*
Expand Down
2 changes: 1 addition & 1 deletion activerecord/activerecord.gemspec
Expand Up @@ -9,7 +9,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 = ">= 2.3.0"
s.required_ruby_version = ">= 2.4.1"

s.license = "MIT"

Expand Down
1 change: 0 additions & 1 deletion activerecord/lib/active_record/base.rb
Expand Up @@ -9,7 +9,6 @@
require "active_support/core_ext/array/extract_options"
require "active_support/core_ext/hash/deep_merge"
require "active_support/core_ext/hash/slice"
require "active_support/core_ext/hash/transform_values"
require "active_support/core_ext/string/behavior"
require "active_support/core_ext/kernel/singleton_class"
require "active_support/core_ext/module/introspection"
Expand Down
7 changes: 7 additions & 0 deletions activestorage/CHANGELOG.md
@@ -1,8 +1,15 @@
## Rails 6.0.0.alpha (Unreleased) ##

* Rails 6 requires Ruby 2.4.1 or newer.

*Jeremy Daer*

* Add source code to published npm package

This allows activestorage users to depend on the javascript source code
rather than the compiled code, which can produce smaller javascript bundles.

*Richard Macklin*


Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activestorage/CHANGELOG.md) for previous changes.
2 changes: 1 addition & 1 deletion activestorage/activestorage.gemspec
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.summary = "Local and cloud file storage framework."
s.description = "Attach cloud and local files in Rails applications."

s.required_ruby_version = ">= 2.3.0"
s.required_ruby_version = ">= 2.4.1"

s.license = "MIT"

Expand Down
13 changes: 10 additions & 3 deletions activesupport/CHANGELOG.md
@@ -1,7 +1,14 @@
* Adds parallel testing to Rails
## Rails 6.0.0.alpha (Unreleased) ##

Parallelize your test suite with forked processes or threads.
* Rails 6 requires Ruby 2.4.1 or newer.

*Jeremy Daer*

* Adds parallel testing to Rails

Parallelize your test suite with forked processes or threads.

*Eileen M. Uchitelle*, *Aaron Patterson*

*Eileen M. Uchitelle*, *Aaron Patterson*

Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activesupport/CHANGELOG.md) for previous changes.
2 changes: 1 addition & 1 deletion activesupport/activesupport.gemspec
Expand Up @@ -9,7 +9,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 = ">= 2.3.0"
s.required_ruby_version = ">= 2.4.1"

s.license = "MIT"

Expand Down
Expand Up @@ -17,7 +17,6 @@

require "digest/sha2"
require "active_support/core_ext/marshal"
require "active_support/core_ext/hash/transform_values"

module ActiveSupport
module Cache
Expand Down
1 change: 0 additions & 1 deletion activesupport/lib/active_support/core_ext/hash.rb
Expand Up @@ -8,4 +8,3 @@
require "active_support/core_ext/hash/keys"
require "active_support/core_ext/hash/reverse_merge"
require "active_support/core_ext/hash/slice"
require "active_support/core_ext/hash/transform_values"
31 changes: 2 additions & 29 deletions activesupport/lib/active_support/core_ext/hash/transform_values.rb
@@ -1,32 +1,5 @@
# frozen_string_literal: true

class Hash
# Returns a new hash with the results of running +block+ once for every value.
# The keys are unchanged.
#
# { a: 1, b: 2, c: 3 }.transform_values { |x| x * 2 } # => { a: 2, b: 4, c: 6 }
#
# If you do not provide a +block+, it will return an Enumerator
# for chaining with other methods:
#
# { a: 1, b: 2 }.transform_values.with_index { |v, i| [v, i].join.to_i } # => { a: 10, b: 21 }
def transform_values
return enum_for(:transform_values) { size } unless block_given?
return {} if empty?
result = self.class.new
each do |key, value|
result[key] = yield(value)
end
result
end unless method_defined? :transform_values
require "active_support/deprecation"

# Destructively converts all values using the +block+ operations.
# Same as +transform_values+ but modifies +self+.
def transform_values!
return enum_for(:transform_values!) { size } unless block_given?
each do |key, value|
self[key] = yield(value)
end
end unless method_defined? :transform_values!
# TODO: Remove this file when supporting only Ruby 2.4+.
end
ActiveSupport::Deprecation.warn "Ruby 2.4+ (required by Rails 6) provides Hash#transform_values natively, so requiring active_support/core_ext/hash/transform_values is no longer necessary. Requiring it will raise LoadError in Rails 6.1."
Expand Up @@ -129,12 +129,6 @@ def to_s(format = nil, options = nil)
end
end

# Ruby 2.4+ unifies Fixnum & Bignum into Integer.
if 0.class == Integer
Integer.prepend ActiveSupport::NumericWithFormat
else
Fixnum.prepend ActiveSupport::NumericWithFormat
Bignum.prepend ActiveSupport::NumericWithFormat
end
Integer.prepend ActiveSupport::NumericWithFormat
Float.prepend ActiveSupport::NumericWithFormat
BigDecimal.prepend ActiveSupport::NumericWithFormat
Expand Up @@ -75,8 +75,11 @@ def duplicable?

class Symbol
begin
:symbol.dup # Ruby 2.4.x.
"symbol_from_string".to_sym.dup # Some symbols can't `dup` in Ruby 2.4.0.
:symbol.dup

# Some symbols couldn't be duped in Ruby 2.4.0 only, due to a bug.
# This feature check catches any regression.
"symbol_from_string".to_sym.dup
rescue TypeError

# Symbols are not duplicable:
Expand Down

2 comments on commit d4eb0dc

@lucascaton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jeremy - it seems that Ruby 2.4.1 has a known memory leak: https://bugs.ruby-lang.org/issues/13772.

I'm happy to submit a PR to change the required Ruby version to 2.4.4 (last from 2.4.x series at the moment), if you think it makes sense.

Thanks.

@jeremy
Copy link
Member Author

@jeremy jeremy commented on d4eb0dc Apr 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ok! Every release will have one issue or another (possibly severe, even). Rails sets the minimum version to match its Ruby API usage only; it doesn't chase point releases or force apps to upgrade. Apps make this decision on their own schedule.

Please sign in to comment.