Skip to content

Commit

Permalink
Rails 6 requires Ruby 2.3+
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Feb 17, 2018
1 parent d352d81 commit 8c412e5
Show file tree
Hide file tree
Showing 38 changed files with 92 additions and 232 deletions.
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ matrix:
- memcached
- redis-server
- rabbitmq
- rvm: 2.3.6
env: "GEM=aj:integration"
services:
- memcached
- redis-server
- rabbitmq
- rvm: 2.4.3
env: "GEM=aj:integration"
services:
Expand Down
3 changes: 0 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ gem "rubocop", ">= 0.47", require: false
# https://github.com/guard/rb-inotify/pull/79
gem "rb-inotify", github: "matthewd/rb-inotify", branch: "close-handling", require: false

# https://github.com/puma/puma/pull/1345
gem "stopgap_13632", platforms: :mri if RUBY_VERSION == "2.2.8"

group :doc do
gem "sdoc", "~> 1.0"
gem "redcarpet", "~> 3.2.3", platforms: :ruby
Expand Down
5 changes: 1 addition & 4 deletions actioncable/lib/action_cable/connection/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,10 @@ def on_close(reason, code) # :nodoc:
send_async :handle_close
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected
private
attr_reader :websocket
attr_reader :message_buffer

private
# The request that initiated the WebSocket connection is available here. This gives access to the environment, cookies, etc.
def request # :doc:
@request ||= begin
Expand Down
5 changes: 1 addition & 4 deletions actioncable/lib/action_cable/connection/message_buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ def process!
receive_buffered_messages
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected
private
attr_reader :connection
attr_reader :buffered_messages

private
def valid?(message)
message.is_a?(String)
end
Expand Down
6 changes: 1 addition & 5 deletions actioncable/lib/action_cable/connection/subscriptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,8 @@ def unsubscribe_from_all
subscriptions.each { |id, channel| remove_subscription(channel) }
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected
attr_reader :connection, :subscriptions

private
attr_reader :connection, :subscriptions
delegate :logger, to: :connection

def find(data)
Expand Down
4 changes: 1 addition & 3 deletions actioncable/lib/action_cable/connection/web_socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def rack_response
websocket.rack_response
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected
private
attr_reader :websocket
end
end
Expand Down
7 changes: 1 addition & 6 deletions actionpack/lib/action_dispatch/http/mime_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,8 @@ def html?

def all?; false; end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected

attr_reader :string, :synonyms

private
attr_reader :string, :synonyms

def to_ary; end
def to_a; end
Expand Down
25 changes: 9 additions & 16 deletions actionpack/test/controller/parameters/accessors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,23 +273,16 @@ class ParametersAccessorsTest < ActiveSupport::TestCase
assert_match(/permitted: true/, @params.inspect)
end

if Hash.method_defined?(:dig)
test "#dig delegates the dig method to its values" do
assert_equal "David", @params.dig(:person, :name, :first)
assert_equal "Chicago", @params.dig(:person, :addresses, 0, :city)
end
test "#dig delegates the dig method to its values" do
assert_equal "David", @params.dig(:person, :name, :first)
assert_equal "Chicago", @params.dig(:person, :addresses, 0, :city)
end

test "#dig converts hashes to parameters" do
assert_kind_of ActionController::Parameters, @params.dig(:person)
assert_kind_of ActionController::Parameters, @params.dig(:person, :addresses, 0)
assert @params.dig(:person, :addresses).all? do |value|
value.is_a?(ActionController::Parameters)
end
end
else
test "ActionController::Parameters does not respond to #dig on Ruby 2.2" do
assert_not ActionController::Parameters.method_defined?(:dig)
assert_not_respond_to @params, :dig
test "#dig converts hashes to parameters" do
assert_kind_of ActionController::Parameters, @params.dig(:person)
assert_kind_of ActionController::Parameters, @params.dig(:person, :addresses, 0)
assert @params.dig(:person, :addresses).all? do |value|
value.is_a?(ActionController::Parameters)
end
end
end
7 changes: 1 addition & 6 deletions actionview/lib/action_view/helpers/tags/translator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@ def translate
translated_attribute || human_attribute_name
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected

attr_reader :object_name, :method_and_value, :scope, :model

private
attr_reader :object_name, :method_and_value, :scope, :model

def i18n_default
if model
Expand Down
7 changes: 1 addition & 6 deletions activemodel/lib/active_model/attribute_mutation_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,8 @@ def force_change(attr_name)
forced_changes << attr_name.to_s
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected

attr_reader :attributes, :forced_changes

private
attr_reader :attributes, :forced_changes

def attr_names
attributes.keys
Expand Down
7 changes: 1 addition & 6 deletions activemodel/lib/active_model/type/integer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@ def serialize(value)
result
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected

attr_reader :range

private
attr_reader :range

def cast_value(value)
case value
Expand Down
12 changes: 2 additions & 10 deletions activemodel/lib/active_model/type/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,8 @@ def lookup(symbol, *args)
end
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected

attr_reader :registrations

private
attr_reader :registrations

def registration_klass
Registration
Expand Down Expand Up @@ -59,10 +54,7 @@ def matches?(type_name, *args, **kwargs)
type_name == name
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected

private
attr_reader :name, :block
end
end
Expand Down
7 changes: 1 addition & 6 deletions activemodel/lib/active_model/validations/acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,8 @@ def define_on(klass)
klass.send(:attr_writer, *attr_writers)
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected

attr_reader :attributes

private
attr_reader :attributes

def convert_to_reader_name(method_name)
method_name.to_s.chomp("=")
Expand Down
2 changes: 1 addition & 1 deletion activemodel/lib/active_model/validations/clusivity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def delimiter
@delimiter ||= options[:in] || options[:within]
end

# In Ruby 2.2 <tt>Range#include?</tt> on non-number-or-time-ish ranges checks all
# After Ruby 2.2, <tt>Range#include?</tt> on non-number-or-time-ish ranges checks all
# possible values in the range for equality, which is slower but more accurate.
# <tt>Range#cover?</tt> uses the previous logic of comparing a value with the range
# endpoints, which is fast but is only accurate on Numeric, Time, Date,
Expand Down
5 changes: 1 addition & 4 deletions activemodel/test/cases/attribute_assignment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ def broken_attribute=(value)
raise ErrorFromAttributeWriter
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected

private
attr_writer :metadata
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,9 @@ def self.get_bind_values(owner, chain)
binds
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected

private
attr_reader :value_transformation

private
def join(table, constraint)
table.create_join(table, table.create_on(constraint))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,8 @@ def add_to(table)
end
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected

attr_reader :name, :polymorphic, :index, :foreign_key, :type, :options

private
attr_reader :name, :polymorphic, :index, :foreign_key, :type, :options

def as_options(value)
value.is_a?(Hash) ? value : {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ def hex?
/\A[0-9A-F]*\Z/i.match?(value)
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected

private
attr_reader :value
end
end
Expand Down
5 changes: 1 addition & 4 deletions activerecord/lib/active_record/enum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,7 @@ def assert_valid_value(value)
end
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected

private
attr_reader :name, :mapping, :subtype
end

Expand Down
65 changes: 30 additions & 35 deletions activerecord/lib/active_record/railties/controller_runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,44 @@ module Railties # :nodoc:
module ControllerRuntime #:nodoc:
extend ActiveSupport::Concern

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected

attr_internal :db_runtime

private

def process_action(action, *args)
# We also need to reset the runtime before each action
# because of queries in middleware or in cases we are streaming
# and it won't be cleaned up by the method below.
ActiveRecord::LogSubscriber.reset_runtime
super
module ClassMethods # :nodoc:
def log_process_action(payload)
messages, db_runtime = super, payload[:db_runtime]
messages << ("ActiveRecord: %.1fms" % db_runtime.to_f) if db_runtime
messages
end
end

def cleanup_view_runtime
if logger && logger.info? && ActiveRecord::Base.connected?
db_rt_before_render = ActiveRecord::LogSubscriber.reset_runtime
self.db_runtime = (db_runtime || 0) + db_rt_before_render
runtime = super
db_rt_after_render = ActiveRecord::LogSubscriber.reset_runtime
self.db_runtime += db_rt_after_render
runtime - db_rt_after_render
else
private
attr_internal :db_runtime

def process_action(action, *args)
# We also need to reset the runtime before each action
# because of queries in middleware or in cases we are streaming
# and it won't be cleaned up by the method below.
ActiveRecord::LogSubscriber.reset_runtime
super
end
end

def append_info_to_payload(payload)
super
if ActiveRecord::Base.connected?
payload[:db_runtime] = (db_runtime || 0) + ActiveRecord::LogSubscriber.reset_runtime
def cleanup_view_runtime
if logger && logger.info? && ActiveRecord::Base.connected?
db_rt_before_render = ActiveRecord::LogSubscriber.reset_runtime
self.db_runtime = (db_runtime || 0) + db_rt_before_render
runtime = super
db_rt_after_render = ActiveRecord::LogSubscriber.reset_runtime
self.db_runtime += db_rt_after_render
runtime - db_rt_after_render
else
super
end
end
end

module ClassMethods # :nodoc:
def log_process_action(payload)
messages, db_runtime = super, payload[:db_runtime]
messages << ("ActiveRecord: %.1fms" % db_runtime.to_f) if db_runtime
messages
def append_info_to_payload(payload)
super
if ActiveRecord::Base.connected?
payload[:db_runtime] = (db_runtime || 0) + ActiveRecord::LogSubscriber.reset_runtime
end
end
end
end
end
end
6 changes: 2 additions & 4 deletions activerecord/lib/active_record/reflection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -962,16 +962,14 @@ def add_as_through(seed)
collect_join_reflections(seed + [self])
end

# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected
attr_reader :delegate_reflection

def actual_source_reflection # FIXME: this is a horrible name
source_reflection.actual_source_reflection
end

private
attr_reader :delegate_reflection

def collect_join_reflections(seed)
a = source_reflection.add_as_source seed
if options[:source_type]
Expand Down

0 comments on commit 8c412e5

Please sign in to comment.