From 84ce53e9259ddfbca5fb7842fceaf77d5df2c06f Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 10:09:30 +0000 Subject: Add Ruby 2.3 to test matrix --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f7259bfd3a..a3699393a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ rvm: - 2.0.0 - 2.1 - 2.2 + - 2.3 env: - "GEM=railties" - "GEM=ap,am,amo,ares,as" -- cgit v1.2.3 From 135e6fb23b0818ba5173f166edeb813685e0f26e Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 10:09:55 +0000 Subject: Prefer https over git for security --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index a81790172a..9507e19716 100644 --- a/Gemfile +++ b/Gemfile @@ -58,7 +58,7 @@ group :doc do # to a bug, but the PR that fixes it has been there # for some weeks unapplied. As a temporary solution # this is our own fork with the fix. - gem 'sdoc', :git => 'git://github.com/fxn/sdoc.git' + gem 'sdoc', :git => 'https://github.com/fxn/sdoc.git' gem 'RedCloth', '~> 4.2' gem 'w3c_validators' end @@ -121,7 +121,7 @@ if ENV['ORACLE_ENHANCED_PATH'] || ENV['ORACLE_ENHANCED'] if ENV['ORACLE_ENHANCED_PATH'] gem 'activerecord-oracle_enhanced-adapter', :path => ENV['ORACLE_ENHANCED_PATH'] else - gem 'activerecord-oracle_enhanced-adapter', :git => 'git://github.com/rsim/oracle-enhanced.git' + gem 'activerecord-oracle_enhanced-adapter', :git => 'https://github.com/rsim/oracle-enhanced.git' end end -- cgit v1.2.3 From e61a279c2b73cb5ac7c9a18b2ff1b8a5a853c16f Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 10:10:27 +0000 Subject: Only list json gem once in Gemfile Bundler gives a warning if you have a gem listed more than once in your Gemfile. Even though they were in different platform blocks it's better to combine them in case it causes a problem later. --- Gemfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 9507e19716..e22d594848 100644 --- a/Gemfile +++ b/Gemfile @@ -68,7 +68,6 @@ gem 'memcache-client', '>= 1.8.5' platforms :mri_18 do gem 'system_timer' - gem 'json' end # Add your own local bundler stuff @@ -99,7 +98,6 @@ platforms :ruby do end platforms :jruby do - gem 'json' gem 'activerecord-jdbcsqlite3-adapter', '>= 1.2.7' # This is needed by now to let tests work on JRuby @@ -113,6 +111,10 @@ platforms :jruby do end end +platforms :mri_18, :jruby do + gem 'json' +end + # gems that are necessary for ActiveRecord tests with Oracle database if ENV['ORACLE_ENHANCED_PATH'] || ENV['ORACLE_ENHANCED'] platforms :ruby do -- cgit v1.2.3 From d3bb345803cc1cad8da1e33f4d39232f15247bd4 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 11:36:32 +0000 Subject: Fix File.exists? deprecation warnings in Active Support --- Gemfile | 2 +- activesupport/lib/active_support/file_update_checker.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index e22d594848..096bbbc324 100644 --- a/Gemfile +++ b/Gemfile @@ -71,7 +71,7 @@ platforms :mri_18 do end # Add your own local bundler stuff -instance_eval File.read '.Gemfile' if File.exists? '.Gemfile' +instance_eval File.read '.Gemfile' if File.exist? '.Gemfile' platforms :mri do group :test do diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb index a4ad2da137..2e0e873fda 100644 --- a/activesupport/lib/active_support/file_update_checker.rb +++ b/activesupport/lib/active_support/file_update_checker.rb @@ -95,7 +95,7 @@ module ActiveSupport def updated_at #:nodoc: @updated_at || begin all = [] - all.concat @files.select { |f| File.exists?(f) } + all.concat @files.select { |f| File.exist?(f) } all.concat Dir[@glob] if @glob all.map { |path| File.mtime(path) }.max || Time.at(0) end -- cgit v1.2.3 From d8fd966b0a2173a006273702ca0d2615577cc220 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 11:37:32 +0000 Subject: Use later versions of nokogiri on 1.9.3+ --- Gemfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 096bbbc324..30713ba5c1 100644 --- a/Gemfile +++ b/Gemfile @@ -81,7 +81,12 @@ end platforms :ruby do gem 'yajl-ruby' - gem 'nokogiri', '>= 1.4.5', '< 1.6' + + if RUBY_VERSION < '1.9.3' + gem 'nokogiri', '>= 1.4.5', '< 1.6' + else + gem 'nokogiri', '>= 1.6.0' + end # AR gem 'sqlite3', '~> 1.3.5' -- cgit v1.2.3 From 48822860f6a3223d752baedbfbfab06d19121024 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 11:38:15 +0000 Subject: Relax dependency of builder gem --- actionpack/actionpack.gemspec | 2 +- activemodel/activemodel.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec index cd906c0cdc..c795e35ac7 100644 --- a/actionpack/actionpack.gemspec +++ b/actionpack/actionpack.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |s| s.add_dependency('activesupport', version) s.add_dependency('activemodel', version) s.add_dependency('rack-cache', '~> 1.2') - s.add_dependency('builder', '~> 3.0.0') + s.add_dependency('builder', '~> 3.0') s.add_dependency('rack', '~> 1.4.5') s.add_dependency('rack-test', '~> 0.6.1') s.add_dependency('journey', '~> 1.0.4') diff --git a/activemodel/activemodel.gemspec b/activemodel/activemodel.gemspec index a4f0836282..ce7037087f 100644 --- a/activemodel/activemodel.gemspec +++ b/activemodel/activemodel.gemspec @@ -19,5 +19,5 @@ Gem::Specification.new do |s| s.require_path = 'lib' s.add_dependency('activesupport', version) - s.add_dependency('builder', '~> 3.0.0') + s.add_dependency('builder', '~> 3.0') end -- cgit v1.2.3 From abe70e8ba18979a4519849f5276a82260f2a4cc4 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 11:39:46 +0000 Subject: Ruby 2.0 added LoadError#path --- activesupport/lib/active_support/core_ext/load_error.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/load_error.rb b/activesupport/lib/active_support/core_ext/load_error.rb index 8bdfa0c5bc..bc575ee176 100644 --- a/activesupport/lib/active_support/core_ext/load_error.rb +++ b/activesupport/lib/active_support/core_ext/load_error.rb @@ -6,12 +6,14 @@ class LoadError /^cannot load such file -- (.+)$/i, ] - def path - @path ||= begin - REGEXPS.find do |regex| - message =~ regex + unless method_defined?(:path) + def path + @path ||= begin + REGEXPS.find do |regex| + message =~ regex + end + $1 end - $1 end end @@ -20,4 +22,4 @@ class LoadError end end -MissingSourceFile = LoadError \ No newline at end of file +MissingSourceFile = LoadError -- cgit v1.2.3 From f762cf05a55b827684b756f6affdcd54923003c0 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 11:40:46 +0000 Subject: Fix AS::OrderHash#select and #reject on Ruby 2.1.1+ In Ruby 2.1.1 and later select and reject return a new instance of Hash rather than the subclass so we need to override them to return an instance of the correct class. --- activesupport/lib/active_support/ordered_hash.rb | 14 ++++++++++++++ activesupport/test/ordered_hash_test.rb | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb index b0d4f2bd86..e81bd013b6 100644 --- a/activesupport/lib/active_support/ordered_hash.rb +++ b/activesupport/lib/active_support/ordered_hash.rb @@ -52,6 +52,20 @@ module ActiveSupport true end + if RUBY_VERSION > '2.1.0' + # On Ruby 2.1.1 and later the behavior of .select and reject changed to + # return a new Hash instance so we need to override them to return an + # instance of the correct class. + + def select(*args, &block) + dup.tap { |hash| hash.select!(*args, &block) } + end + + def reject(*args, &block) + dup.tap { |hash| hash.reject!(*args, &block) } + end + end + # Hash is ordered in Ruby 1.9! if RUBY_VERSION < '1.9' diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb index a7fd9402c8..bbaccf2594 100644 --- a/activesupport/test/ordered_hash_test.rb +++ b/activesupport/test/ordered_hash_test.rb @@ -125,6 +125,9 @@ class OrderedHashTest < Test::Unit::TestCase def test_select assert_equal @keys, @ordered_hash.select { true }.map(&:first) + new_ordered_hash = @ordered_hash.select { true } + assert_equal @keys, new_ordered_hash.map(&:first) + assert_instance_of ActiveSupport::OrderedHash, new_ordered_hash end def test_delete_if @@ -147,6 +150,7 @@ class OrderedHashTest < Test::Unit::TestCase assert_equal copy, @ordered_hash assert !new_ordered_hash.keys.include?('pink') assert @ordered_hash.keys.include?('pink') + assert_instance_of ActiveSupport::OrderedHash, new_ordered_hash end def test_clear -- cgit v1.2.3 From b82fa5cd2e39bf400f61478173885d6c0b480384 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 11:43:27 +0000 Subject: Fix warning with ambiguous *args --- activesupport/lib/active_support/tagged_logging.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/tagged_logging.rb b/activesupport/lib/active_support/tagged_logging.rb index 232c367d26..19a003757f 100644 --- a/activesupport/lib/active_support/tagged_logging.rb +++ b/activesupport/lib/active_support/tagged_logging.rb @@ -78,7 +78,7 @@ module ActiveSupport end else def respond_to_missing?(*args) - @logger.respond_to? *args + @logger.respond_to?(*args) end end -- cgit v1.2.3 From 21186270288ef3f8816cecf0aad1e1c537493bee Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 11:44:05 +0000 Subject: Fix warning about unset I18n.enforce_available_locales --- actionmailer/test/abstract_unit.rb | 3 +++ actionpack/test/abstract_unit.rb | 3 +++ activemodel/test/cases/helper.rb | 3 +++ activerecord/test/cases/helper.rb | 3 +++ activeresource/test/abstract_unit.rb | 3 +++ activesupport/test/abstract_unit.rb | 3 +++ 6 files changed, 18 insertions(+) diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index 0b076e1ff9..0e35a88e9f 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -42,6 +42,9 @@ ActiveSupport::Deprecation.debug = true ActionView::Template.register_template_handler :haml, lambda { |template| "Look its HAML!".inspect } ActionView::Template.register_template_handler :bak, lambda { |template| "Lame backup".inspect } +# Disable available locale checks to avoid warnings running the test suite. +I18n.enforce_available_locales = false + FIXTURE_LOAD_PATH = File.expand_path('fixtures', File.dirname(__FILE__)) ActionMailer::Base.view_paths = FIXTURE_LOAD_PATH diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 74efcba666..7ea2c5f061 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -51,6 +51,9 @@ ActiveSupport::Dependencies.hook! # Show backtraces for deprecated behavior for quicker cleanup. ActiveSupport::Deprecation.debug = true +# Disable available locale checks to avoid warnings running the test suite. +I18n.enforce_available_locales = false + # Register danish language for testing I18n.backend.store_translations 'da', {} I18n.backend.store_translations 'pt-BR', {} diff --git a/activemodel/test/cases/helper.rb b/activemodel/test/cases/helper.rb index 2e860272a4..84f6a464cd 100644 --- a/activemodel/test/cases/helper.rb +++ b/activemodel/test/cases/helper.rb @@ -10,4 +10,7 @@ require 'active_support/core_ext/string/access' # Show backtraces for deprecated behavior for quicker cleanup. ActiveSupport::Deprecation.debug = true +# Disable available locale checks to avoid warnings running the test suite. +I18n.enforce_available_locales = false + require 'test/unit' diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index cf49b125d7..e3374bb36f 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -17,6 +17,9 @@ require 'support/connection' # Show backtraces for deprecated behavior for quicker cleanup. ActiveSupport::Deprecation.debug = true +# Disable available locale checks to avoid warnings running the test suite. +I18n.enforce_available_locales = false + # Enable Identity Map only when ENV['IM'] is set to "true" ActiveRecord::IdentityMap.enabled = (ENV['IM'] == "true") diff --git a/activeresource/test/abstract_unit.rb b/activeresource/test/abstract_unit.rb index 583fd2afb7..90ca772211 100644 --- a/activeresource/test/abstract_unit.rb +++ b/activeresource/test/abstract_unit.rb @@ -13,6 +13,9 @@ require 'setter_trap' require 'logger' ActiveResource::Base.logger = Logger.new("#{File.dirname(__FILE__)}/debug.log") +# Disable available locale checks to avoid warnings running the test suite. +I18n.enforce_available_locales = false + def setup_response matz_hash = { 'person' => { :id => 1, :name => 'Matz' } } diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index c26a48a490..a777708e0c 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -30,6 +30,9 @@ silence_warnings { require 'mocha/setup' } ENV['NO_RELOAD'] = '1' require 'active_support' +# Disable available locale checks to avoid warnings running the test suite. +I18n.enforce_available_locales = false + # Include shims until we get off 1.8.6 require 'active_support/ruby/shim' if RUBY_VERSION < '1.8.7' -- cgit v1.2.3 From 03e3aed60264ae0d12dfdf7a0c57044da49af148 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 12:06:51 +0000 Subject: Fix AS::HWIA#select and #reject on Ruby 2.1.1+ In Ruby 2.1.1 and later select and reject return a new instance of Hash rather than the subclass so we need to override them to return an instance of the correct class. --- .../active_support/hash_with_indifferent_access.rb | 14 ++++++++++ activesupport/test/core_ext/hash_ext_test.rb | 30 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index 9dc93de5a9..f89704d906 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -153,6 +153,20 @@ module ActiveSupport def symbolize_keys; to_hash.symbolize_keys end def to_options!; self end + if RUBY_VERSION > '2.1.0' + # On Ruby 2.1.1 and later the behavior of .select and reject changed to + # return a new Hash instance so we need to override them to return an + # instance of the correct class. + + def select(*args, &block) + dup.tap { |hash| hash.select!(*args, &block) } + end + + def reject(*args, &block) + dup.tap { |hash| hash.reject!(*args, &block) } + end + end + # Convert to a Hash with String keys. def to_hash Hash.new(default).merge!(self) diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index c3a59540fb..8c032dc880 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -259,6 +259,36 @@ class HashExtTest < Test::Unit::TestCase assert_equal hash.delete('a'), nil end + def test_indifferent_select + hash = ActiveSupport::HashWithIndifferentAccess.new(@strings).select { |k, v| v == 1 } + + assert_equal({ "a" => 1 }, hash) + assert_instance_of ActiveSupport::HashWithIndifferentAccess, hash + end + + def test_indifferent_select_bang + indifferent_strings = ActiveSupport::HashWithIndifferentAccess.new(@strings) + indifferent_strings.select! { |k, v| v == 1 } + + assert_equal({ "a" => 1 }, indifferent_strings) + assert_instance_of ActiveSupport::HashWithIndifferentAccess, indifferent_strings + end + + def test_indifferent_reject + hash = ActiveSupport::HashWithIndifferentAccess.new(@strings).reject { |k, v| v != 1 } + + assert_equal({ "a" => 1 }, hash) + assert_instance_of ActiveSupport::HashWithIndifferentAccess, hash + end + + def test_indifferent_reject_bang + indifferent_strings = ActiveSupport::HashWithIndifferentAccess.new(@strings) + indifferent_strings.reject! { |k, v| v != 1 } + + assert_equal({ "a" => 1 }, indifferent_strings) + assert_instance_of ActiveSupport::HashWithIndifferentAccess, indifferent_strings + end + def test_indifferent_to_hash # Should convert to a Hash with String keys. assert_equal @strings, @mixed.with_indifferent_access.to_hash -- cgit v1.2.3 From 6341c1c698e69fdaba4fd212d16ab3e8979e9c6e Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 13:38:36 +0000 Subject: Fix method redefinition warnings in i18n gem The i18n gem adds its own copies of deep_merge, except and slice if they haven't been defined so require them early to prevent any method redefinition warnings from appearing. --- activesupport/lib/active_support/i18n.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/activesupport/lib/active_support/i18n.rb b/activesupport/lib/active_support/i18n.rb index f9c5e5e2f8..978e87beda 100644 --- a/activesupport/lib/active_support/i18n.rb +++ b/activesupport/lib/active_support/i18n.rb @@ -1,3 +1,7 @@ +require 'active_support/core_ext/hash/deep_merge' +require 'active_support/core_ext/hash/except' +require 'active_support/core_ext/hash/slice' + begin require 'i18n' require 'active_support/lazy_load_hooks' -- cgit v1.2.3 From 1f62443319c1b95c6e747a5de5e7e1041c64cbcb Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 16:00:37 +0000 Subject: Fix inconsistencies in path with missing helpers Ruby 2.0 and later demonstrate some inconsistencies when a helper file is not found with the path method on LoadError. By creating a subclass of LoadError we can cater for the inconsistencies. --- actionpack/lib/abstract_controller/helpers.rb | 15 ++++++++++++++- actionpack/test/abstract/helper_test.rb | 5 ++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb index 77cc4c07d9..7a9055a679 100644 --- a/actionpack/lib/abstract_controller/helpers.rb +++ b/actionpack/lib/abstract_controller/helpers.rb @@ -12,6 +12,15 @@ module AbstractController self._helper_methods = Array.new end + class MissingHelperError < LoadError + def initialize(error, path) + @error = error + @path = "helpers/#{path}.rb" + set_backtrace error.backtrace + super("Missing helper file helpers/%s.rb" % path) + end + end + module ClassMethods # When a class is inherited, wrap its helper module in a new module. # This ensures that the parent class's module can be changed @@ -132,7 +141,11 @@ module AbstractController case arg when String, Symbol file_name = "#{arg.to_s.underscore}_helper" - require_dependency(file_name, "Missing helper file helpers/%s.rb") + begin + require_dependency(file_name) + rescue LoadError => e + raise MissingHelperError.new(e, file_name) + end file_name.camelize.constantize when Module arg diff --git a/actionpack/test/abstract/helper_test.rb b/actionpack/test/abstract/helper_test.rb index b28a5b5afb..2e86e7e859 100644 --- a/actionpack/test/abstract/helper_test.rb +++ b/actionpack/test/abstract/helper_test.rb @@ -69,7 +69,10 @@ module AbstractController end def test_declare_missing_helper - assert_raise(MissingSourceFile) { AbstractHelpers.helper :missing } + e = assert_raise AbstractController::Helpers::MissingHelperError do + AbstractHelpers.helper :missing + end + assert_equal "helpers/missing_helper.rb", e.path end def test_helpers_with_module_through_block -- cgit v1.2.3 From 2b1ec283d41898cbe1e2f60f72ed40ebc0d2672a Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 16:07:24 +0000 Subject: Fix File.exists? deprecation warnings in Action Pack --- .../lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb | 2 +- actionpack/lib/sprockets/helpers/rails_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb index 05d5f1870a..edfc374b3b 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb @@ -47,7 +47,7 @@ module ActionView if concat || (config.perform_caching && cache) joined_name = (cache == true ? "all" : cache) + ".#{extension}" joined_path = File.join((joined_name[/^#{File::SEPARATOR}/] ? config.assets_dir : custom_dir), joined_name) - unless config.perform_caching && File.exists?(joined_path) + unless config.perform_caching && File.exist?(joined_path) write_asset_file_contents(joined_path, compute_paths(sources, recursive)) end asset_tag(joined_name, options) diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index 243c2e5e50..6712aefb2d 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -163,7 +163,7 @@ module Sprockets source elsif source_ext.blank? "#{source}.#{ext}" - elsif File.exists?(source) || exact_match_present?(source) + elsif File.exist?(source) || exact_match_present?(source) source else "#{source}.#{ext}" -- cgit v1.2.3 From b12b4be0b8070a0e16f7ab0125c4f0aec1766bcc Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 16:13:26 +0000 Subject: Double assign locals to avoid unused variables warning --- actionpack/lib/action_view/template.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index e67e52cc76..069ac4e761 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -323,7 +323,8 @@ module ActionView end def locals_code #:nodoc: - @locals.map { |key| "#{key} = local_assigns[:#{key}];" }.join + # Double assign to suppress the dreaded 'assigned but unused variable' warning + @locals.map { |key| "#{key} = #{key} = local_assigns[:#{key}];" }.join end def method_name #:nodoc: -- cgit v1.2.3 From 24ca0154a355200283fc20a595983f81aa1c7cb2 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 16:18:38 +0000 Subject: Remove duplicate prompt key from options --- actionpack/test/template/date_helper_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb index ad46ff4429..ea4b1611cf 100644 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -1386,7 +1386,7 @@ class DateHelperTest < ActionView::TestCase expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true, :include_seconds => true, + assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true, :prompt => {:hour => 'Choose hour', :minute => 'Choose minute', :second => 'Choose seconds'}) end -- cgit v1.2.3 From 4f2de3480c8bbdb928e3b3c6e71674f8c5992a60 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 16:48:43 +0000 Subject: Fix deprecation warnings on URI.unescape --- .../connection_adapters/abstract/connection_specification.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb index 04ab7e0a43..cd1575d049 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb @@ -1,4 +1,5 @@ require 'uri' +require 'active_support/core_ext/uri' module ActiveRecord class Base @@ -68,7 +69,7 @@ module ActiveRecord :database => config.path.sub(%r{^/},""), :host => config.host } spec.reject!{ |_,value| value.blank? } - spec.map { |key,value| spec[key] = URI.unescape(value) if value.is_a?(String) } + spec.map { |key,value| spec[key] = URI.parser.unescape(value) if value.is_a?(String) } if config.query options = Hash[config.query.split("&").map{ |pair| pair.split("=") }].symbolize_keys spec.merge!(options) -- cgit v1.2.3 From 6e167d38e25186419ef26e9755ba6f4e3f709722 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 16:49:18 +0000 Subject: Fix raising uniqueness constraints in newer versions of SQLite Versions 3.8.2 and later of SQLite changed the formatting of the error messages returned when a uniqueness constraint was violated. --- .../lib/active_record/connection_adapters/sqlite_adapter.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index 455560aa55..f3a47ba80a 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -571,7 +571,11 @@ module ActiveRecord def translate_exception(exception, message) case exception.message - when /column(s)? .* (is|are) not unique/ + # SQLite 3.8.2 returns a newly formatted error message: + # UNIQUE constraint failed: *table_name*.*column_name* + # Older versions of SQLite return: + # column *column_name* is not unique + when /column(s)? .* (is|are) not unique/, /UNIQUE constraint failed: .*/ RecordNotUnique.new(message, exception) else super -- cgit v1.2.3 From 48750b434f4f96821f464c74df73e8cc22d9fb07 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 16:52:22 +0000 Subject: Fix File.exists? deprecation warnings in Active Record --- activerecord/lib/active_record/migration.rb | 2 +- .../lib/active_record/railties/databases.rake | 2 +- activerecord/test/cases/helper.rb | 2 +- activerecord/test/cases/migration_test.rb | 36 +++++++++++----------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index e8ec93470d..546a60e702 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -470,7 +470,7 @@ module ActiveRecord def copy(destination, sources, options = {}) copied = [] - FileUtils.mkdir_p(destination) unless File.exists?(destination) + FileUtils.mkdir_p(destination) unless File.exist?(destination) destination_migrations = ActiveRecord::Migrator.migrations(destination) last = destination_migrations.last diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index b8aed49854..44e2d2603e 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -398,7 +398,7 @@ db_namespace = namespace :db do desc 'Load a schema.rb file into the database' task :load => [:environment, :load_config] do file = ENV['SCHEMA'] || "#{Rails.root}/db/schema.rb" - if File.exists?(file) + if File.exist?(file) load(file) else abort %{#{file} doesn't exist yet. Run `rake db:migrate` to create it then try again. If you do not intend to use a database, you should instead alter #{Rails.root}/config/application.rb to limit the frameworks that will be loaded} diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index e3374bb36f..f5d226160d 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -127,7 +127,7 @@ def load_schema load SCHEMA_ROOT + "/schema.rb" - if File.exists?(adapter_specific_schema_file) + if File.exist?(adapter_specific_schema_file) load adapter_specific_schema_file end ensure diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 7f0d921545..917328231d 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -2199,8 +2199,8 @@ if ActiveRecord::Base.connection.supports_migrations? @existing_migrations = Dir[@migrations_path + "/*.rb"] copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy"}) - assert File.exists?(@migrations_path + "/4_people_have_hobbies.bukkits.rb") - assert File.exists?(@migrations_path + "/5_people_have_descriptions.bukkits.rb") + assert File.exist?(@migrations_path + "/4_people_have_hobbies.bukkits.rb") + assert File.exist?(@migrations_path + "/5_people_have_descriptions.bukkits.rb") assert_equal [@migrations_path + "/4_people_have_hobbies.bukkits.rb", @migrations_path + "/5_people_have_descriptions.bukkits.rb"], copied.map(&:filename) expected = "# This migration comes from bukkits (originally 1)" @@ -2223,10 +2223,10 @@ if ActiveRecord::Base.connection.supports_migrations? sources[:bukkits] = MIGRATIONS_ROOT + "/to_copy" sources[:omg] = MIGRATIONS_ROOT + "/to_copy2" ActiveRecord::Migration.copy(@migrations_path, sources) - assert File.exists?(@migrations_path + "/4_people_have_hobbies.bukkits.rb") - assert File.exists?(@migrations_path + "/5_people_have_descriptions.bukkits.rb") - assert File.exists?(@migrations_path + "/6_create_articles.omg.rb") - assert File.exists?(@migrations_path + "/7_create_comments.omg.rb") + assert File.exist?(@migrations_path + "/4_people_have_hobbies.bukkits.rb") + assert File.exist?(@migrations_path + "/5_people_have_descriptions.bukkits.rb") + assert File.exist?(@migrations_path + "/6_create_articles.omg.rb") + assert File.exist?(@migrations_path + "/7_create_comments.omg.rb") files_count = Dir[@migrations_path + "/*.rb"].length ActiveRecord::Migration.copy(@migrations_path, sources) @@ -2241,8 +2241,8 @@ if ActiveRecord::Base.connection.supports_migrations? Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) - assert File.exists?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb") - assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb") + assert File.exist?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb") + assert File.exist?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb") expected = [@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb", @migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb"] assert_equal expected, copied.map(&:filename) @@ -2266,10 +2266,10 @@ if ActiveRecord::Base.connection.supports_migrations? Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do copied = ActiveRecord::Migration.copy(@migrations_path, sources) - assert File.exists?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb") - assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb") - assert File.exists?(@migrations_path + "/20100726101012_create_articles.omg.rb") - assert File.exists?(@migrations_path + "/20100726101013_create_comments.omg.rb") + assert File.exist?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb") + assert File.exist?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb") + assert File.exist?(@migrations_path + "/20100726101012_create_articles.omg.rb") + assert File.exist?(@migrations_path + "/20100726101013_create_comments.omg.rb") assert_equal 4, copied.length files_count = Dir[@migrations_path + "/*.rb"].length @@ -2286,8 +2286,8 @@ if ActiveRecord::Base.connection.supports_migrations? Time.travel_to(Time.utc(2010, 2, 20, 10, 10, 10)) do ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) - assert File.exists?(@migrations_path + "/20100301010102_people_have_hobbies.bukkits.rb") - assert File.exists?(@migrations_path + "/20100301010103_people_have_descriptions.bukkits.rb") + assert File.exist?(@migrations_path + "/20100301010102_people_have_hobbies.bukkits.rb") + assert File.exist?(@migrations_path + "/20100301010103_people_have_descriptions.bukkits.rb") files_count = Dir[@migrations_path + "/*.rb"].length copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) @@ -2341,8 +2341,8 @@ if ActiveRecord::Base.connection.supports_migrations? Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) - assert File.exists?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb") - assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb") + assert File.exist?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb") + assert File.exist?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb") assert_equal 2, copied.length end ensure @@ -2356,8 +2356,8 @@ if ActiveRecord::Base.connection.supports_migrations? Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) - assert File.exists?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb") - assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb") + assert File.exist?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb") + assert File.exist?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb") assert_equal 2, copied.length end ensure -- cgit v1.2.3 From db3374c428ec71fbcede2f8153c553ccbe0f1832 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 20:14:17 +0000 Subject: Only override to_yaml if YAML::ENGINE is defined The Syck engine has been removed from later versions of Ruby so no need to override to_yaml for these versions. --- activerecord/lib/active_record/base.rb | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 5bd1721439..181c072211 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -648,24 +648,26 @@ module ActiveRecord #:nodoc: "#<#{self.class} #{inspection}>" end - # Hackery to accomodate Syck. Remove for 4.0. - def to_yaml(opts = {}) #:nodoc: - if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck? - super - else - coder = {} - encode_with(coder) - YAML.quick_emit(self, opts) do |out| - out.map(taguri, to_yaml_style) do |map| - coder.each { |k, v| map.add(k, v) } + if YAML.const_defined?(:ENGINE) + # Hackery to accomodate Syck. Remove for 4.0. + def to_yaml(opts = {}) #:nodoc: + if !YAML::ENGINE.syck? + super + else + coder = {} + encode_with(coder) + YAML.quick_emit(self, opts) do |out| + out.map(taguri, to_yaml_style) do |map| + coder.each { |k, v| map.add(k, v) } + end end end end - end - # Hackery to accomodate Syck. Remove for 4.0. - def yaml_initialize(tag, coder) #:nodoc: - init_with(coder) + # Hackery to accomodate Syck. Remove for 4.0. + def yaml_initialize(tag, coder) #:nodoc: + init_with(coder) + end end private -- cgit v1.2.3 From ddeabad059086ce76771962e71a9cdf24324db3d Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 2 Nov 2016 20:16:26 +0000 Subject: Fix indenting --- activerecord/test/cases/relations_test.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 39632075e8..6d887ce123 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -669,11 +669,11 @@ class RelationTest < ActiveRecord::TestCase end def test_relation_merging_with_arel_equalities_keeps_last_equality - devs = Developer.where(Developer.arel_table[:salary].eq(80000)).merge( - Developer.where(Developer.arel_table[:salary].eq(9000)) - ) - assert_equal [developers(:poor_jamis)], devs.to_a - end + devs = Developer.where(Developer.arel_table[:salary].eq(80000)).merge( + Developer.where(Developer.arel_table[:salary].eq(9000)) + ) + assert_equal [developers(:poor_jamis)], devs.to_a + end def test_relation_merging_with_arel_equalities_with_a_non_attribute_left_hand_ignores_non_attributes_when_discarding_equalities salary_attr = Developer.arel_table[:salary] @@ -681,7 +681,7 @@ class RelationTest < ActiveRecord::TestCase Developer.where(salary_attr.eq(9000)).where(Arel::Nodes::NamedFunction.new('abs', [salary_attr]).eq(9000)) ) assert_equal [developers(:poor_jamis)], devs.to_a - end + end def test_relation_merging_with_eager_load relations = [] -- cgit v1.2.3 From ccbeea0a77df995e62e59289e89aeb242fcf742c Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 3 Nov 2016 10:59:25 +0000 Subject: Fix uninitialized warning with @new_record instance variable Initializing @stale_state to nil when an association is built fixes a marshalling error - see #5268 for more details. --- activerecord/lib/active_record/associations/association.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index abee941c07..7cdaf78223 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -28,6 +28,7 @@ module ActiveRecord @target = nil @owner, @reflection = owner, reflection @updated = false + @stale_state = nil reset reset_scope -- cgit v1.2.3 From 656d9e7673e8f7aad34e38a9251b468ab8d3bb3f Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 3 Nov 2016 11:01:53 +0000 Subject: Remove unused local variable --- activerecord/test/cases/adapters/postgresql/bytea_test.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/activerecord/test/cases/adapters/postgresql/bytea_test.rb b/activerecord/test/cases/adapters/postgresql/bytea_test.rb index 5ed2d8aba2..9b8441c027 100644 --- a/activerecord/test/cases/adapters/postgresql/bytea_test.rb +++ b/activerecord/test/cases/adapters/postgresql/bytea_test.rb @@ -33,7 +33,6 @@ class PostgresqlByteaTest < ActiveRecord::TestCase end def test_serialize - serializer = Serializer.new klass = Class.new(ByteaDataType) { serialize :serialized, Serializer.new } -- cgit v1.2.3 From bee2f6d317cd186b5a6c1fe6d03caca545aa881c Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 3 Nov 2016 11:02:14 +0000 Subject: Remove migration constants to avoid method redefined warnings --- activerecord/test/cases/migration_test.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 917328231d..f74085fc7f 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -1786,10 +1786,14 @@ if ActiveRecord::Base.connection.supports_migrations? def test_migrator_interleaved_migrations ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/interleaved/pass_1") + Object.send :remove_const, :InterleavedInnocentJointable + assert_nothing_raised do ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/interleaved/pass_2") end + Object.send :remove_const, :InterleavedPeopleHaveLastNames + Person.reset_column_information assert Person.column_methods_hash.include?(:last_name) -- cgit v1.2.3 From 4267db8ed6e68a703858fcdc2defe95bee83156d Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 3 Nov 2016 11:47:08 +0000 Subject: Flushing all logs fixed in Ruby 2.3 Previously, flushing all logs in Ruby 2.0 and later would raise an exception when there was no DATABASE_URL or database.yml. Whatever was the cause of that seems to have been fixed in Ruby 2.3. --- railties/test/application/initializers/active_record_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/railties/test/application/initializers/active_record_test.rb b/railties/test/application/initializers/active_record_test.rb index b62943a278..d823577a3d 100644 --- a/railties/test/application/initializers/active_record_test.rb +++ b/railties/test/application/initializers/active_record_test.rb @@ -25,8 +25,8 @@ module ApplicationTests # ActiveSupport::LogSubscriber.flush_all! in lib/rails/rack/logger.rb blew up in Ruby 2.0 # because it tries to open the database. This behavior doesn't happen in Ruby 1.9.3. - # However, regardless, the server blew up. - if RUBY_VERSION >= '2.0.0' + # However, regardless, the server blew up. This appears to be fixed in 2.3.0. + if RUBY_VERSION >= '2.0.0' && RUBY_VERSION < '2.3.0' assert_raises (Errno::ENOENT) { get '/foo' } else get '/foo' -- cgit v1.2.3 From 13877d378785111e39ed94e223209e4c319ee147 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 3 Nov 2016 13:10:26 +0000 Subject: The pg gem has started requiring Ruby 2.0+ from 0.19.0 --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 30713ba5c1..8dffcee105 100644 --- a/Gemfile +++ b/Gemfile @@ -94,6 +94,8 @@ platforms :ruby do group :db do if RUBY_VERSION < '1.9.3' gem 'pg', '>= 0.11.0', '< 0.18' + elsif RUBY_VERSION < '2.0.0' + gem 'pg', '>= 0.11.0', '< 0.19' else gem 'pg', '>= 0.11.0' end -- cgit v1.2.3 From ad698754a14094211b6265e2e1576df2aca3a3c2 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 3 Nov 2016 13:18:16 +0000 Subject: Start memcached for Action Pack and Active Support tests --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index a3699393a5..33b2fc9075 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,9 @@ language: ruby sudo: false +services: + - memcached + script: 'ci/travis.rb' before_install: - gem install bundler -- cgit v1.2.3 From 47d588246e8d7618b2c6ff810b3ece6624acd25c Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 3 Nov 2016 13:21:50 +0000 Subject: Cache bundle install on Travis --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 33b2fc9075..6e1ab6c4f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,9 @@ language: ruby sudo: false +cache: + bundler: true + services: - memcached -- cgit v1.2.3 From bbe5e07f7a01d4c12767750e6280ce8f56d89070 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 3 Nov 2016 13:33:14 +0000 Subject: Update travis.yml to match master where appropriate --- .travis.yml | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6e1ab6c4f0..d1f24208a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,24 +7,40 @@ cache: services: - memcached -script: 'ci/travis.rb' +bundler_args: --without test --jobs 3 --retry 3 before_install: - gem install bundler + +before_script: + - bundle update + +script: 'ci/travis.rb' + +env: + matrix: + - "GEM=railties" + - "GEM=ap,am,amo,ares,as" + - "GEM=ar:mysql" + - "GEM=ar:mysql2" + - "GEM=ar:sqlite3" + - "GEM=ar:postgresql" + rvm: - 1.8.7 - 1.9.2 - 1.9.3 - 2.0.0 - - 2.1 - - 2.2 - - 2.3 -env: - - "GEM=railties" - - "GEM=ap,am,amo,ares,as" - - "GEM=ar:mysql" - - "GEM=ar:mysql2" - - "GEM=ar:sqlite3" - - "GEM=ar:postgresql" + - 2.1.8 + - 2.2.5 + - 2.3.1 + +# Railties specs on Ruby 1.8.7 are broken. +# Last recorded passing CI run is https://travis-ci.org/rails/rails/builds/48782330 +matrix: + allow_failures: + - rvm: 1.8.7 + env: GEM=railties + notifications: email: false irc: @@ -37,11 +53,3 @@ notifications: on_failure: always rooms: - secure: "YA1alef1ESHWGFNVwvmVGCkMe4cUy4j+UcNvMUESraceiAfVyRMAovlQBGs6\n9kBRm7DHYBUXYC2ABQoJbQRLDr/1B5JPf/M8+Qd7BKu8tcDC03U01SMHFLpO\naOs/HLXcDxtnnpL07tGVsm0zhMc5N8tq4/L3SHxK7Vi+TacwQzI=" -bundler_args: --path vendor/bundle - -# Railties specs on Ruby 1.8.7 are broken. -# Last recorded passing CI run is https://travis-ci.org/rails/rails/builds/48782330 -matrix: - allow_failures: - - rvm: 1.8.7 - env: GEM=railties -- cgit v1.2.3 From 7cef8061ab98261887001f8c6fba3f52a85dbaa8 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 3 Nov 2016 14:15:29 +0000 Subject: Adjust tests for differences between Ruby 1.8 and 1.9 Ruby 1.9 added Hash#select! and return a hash from Hash#select whereas Ruby 1.8 returned an array. --- .../active_support/hash_with_indifferent_access.rb | 6 +----- activesupport/lib/active_support/ordered_hash.rb | 6 +----- activesupport/test/core_ext/hash_ext_test.rb | 23 +++++++++++++++------- activesupport/test/ordered_hash_test.rb | 8 +++++++- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index f89704d906..c02bd60fde 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -153,11 +153,7 @@ module ActiveSupport def symbolize_keys; to_hash.symbolize_keys end def to_options!; self end - if RUBY_VERSION > '2.1.0' - # On Ruby 2.1.1 and later the behavior of .select and reject changed to - # return a new Hash instance so we need to override them to return an - # instance of the correct class. - + if RUBY_VERSION > '1.9' def select(*args, &block) dup.tap { |hash| hash.select!(*args, &block) } end diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb index e81bd013b6..0f9caca892 100644 --- a/activesupport/lib/active_support/ordered_hash.rb +++ b/activesupport/lib/active_support/ordered_hash.rb @@ -52,11 +52,7 @@ module ActiveSupport true end - if RUBY_VERSION > '2.1.0' - # On Ruby 2.1.1 and later the behavior of .select and reject changed to - # return a new Hash instance so we need to override them to return an - # instance of the correct class. - + if RUBY_VERSION > '1.9' def select(*args, &block) dup.tap { |hash| hash.select!(*args, &block) } end diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 8c032dc880..f29b91a324 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -262,16 +262,25 @@ class HashExtTest < Test::Unit::TestCase def test_indifferent_select hash = ActiveSupport::HashWithIndifferentAccess.new(@strings).select { |k, v| v == 1 } - assert_equal({ "a" => 1 }, hash) - assert_instance_of ActiveSupport::HashWithIndifferentAccess, hash + if RUBY_VERSION > '1.9' + assert_equal({ "a" => 1 }, hash) + assert_instance_of ActiveSupport::HashWithIndifferentAccess, hash + else + # Ruby 1.8.7 returns an Array from Hash#select + assert_equal([["a", 1]], hash) + assert_instance_of Array, hash + end end - def test_indifferent_select_bang - indifferent_strings = ActiveSupport::HashWithIndifferentAccess.new(@strings) - indifferent_strings.select! { |k, v| v == 1 } + if RUBY_VERSION > '1.9' + # Hash#select! was added in Ruby 1.9 + def test_indifferent_select_bang + indifferent_strings = ActiveSupport::HashWithIndifferentAccess.new(@strings) + indifferent_strings.select! { |k, v| v == 1 } - assert_equal({ "a" => 1 }, indifferent_strings) - assert_instance_of ActiveSupport::HashWithIndifferentAccess, indifferent_strings + assert_equal({ "a" => 1 }, indifferent_strings) + assert_instance_of ActiveSupport::HashWithIndifferentAccess, indifferent_strings + end end def test_indifferent_reject diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb index bbaccf2594..31eeb7f565 100644 --- a/activesupport/test/ordered_hash_test.rb +++ b/activesupport/test/ordered_hash_test.rb @@ -127,7 +127,13 @@ class OrderedHashTest < Test::Unit::TestCase assert_equal @keys, @ordered_hash.select { true }.map(&:first) new_ordered_hash = @ordered_hash.select { true } assert_equal @keys, new_ordered_hash.map(&:first) - assert_instance_of ActiveSupport::OrderedHash, new_ordered_hash + + if RUBY_VERSION > '1.9' + assert_instance_of ActiveSupport::OrderedHash, new_ordered_hash + else + # Ruby 1.8.7 returns an Array from Hash#select + assert_instance_of Array, new_ordered_hash + end end def test_delete_if -- cgit v1.2.3 From 707f59042a58d329f8237ba5af1af8bca51e2266 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 3 Nov 2016 15:11:05 +0000 Subject: Tweak conditionals on YAML handling There's no YAML::ENGINE constant in Ruby 1.8 and Ruby 2.2+ but the former still needs to use the deprecated Syck behavior. --- activerecord/lib/active_record/base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 181c072211..77ad428685 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -648,10 +648,10 @@ module ActiveRecord #:nodoc: "#<#{self.class} #{inspection}>" end - if YAML.const_defined?(:ENGINE) + if RUBY_VERSION < '2.2' # Hackery to accomodate Syck. Remove for 4.0. def to_yaml(opts = {}) #:nodoc: - if !YAML::ENGINE.syck? + if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck? super else coder = {} -- cgit v1.2.3 From 47c1aee5641dab399d3eb0b0089f31fcdb2eee41 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 3 Nov 2016 17:23:29 +0000 Subject: Fix method redefined warnings for + and - on Time The power_assert gem has a workaround for a Ruby 2.3 bug[1] which causes method refined warnings with operator methods on Time. Work around the workaround by loading Active Support time extensions before loading the test-unit gem. [1]: https://bugs.ruby-lang.org/issues/11182 --- activesupport/test/abstract_unit.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index a777708e0c..cbe491eb73 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -22,14 +22,15 @@ if "ruby".encoding_aware? end end +ENV['NO_RELOAD'] = '1' +require 'active_support' +require 'active_support/time' + require 'test/unit' require 'empty_bool' silence_warnings { require 'mocha/setup' } -ENV['NO_RELOAD'] = '1' -require 'active_support' - # Disable available locale checks to avoid warnings running the test suite. I18n.enforce_available_locales = false -- cgit v1.2.3 From cf3a0643a290fbf839dce3ba0ec1437591c52b65 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 3 Nov 2016 20:55:57 +0000 Subject: Reinstate railties tests on Ruby 1.8.7 Something changed in Bundler 1.12.0 that caused the railties tests to start failing so lock the bundler version to 1.11.2. --- .travis.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index d1f24208a3..810ddeb65d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ services: bundler_args: --without test --jobs 3 --retry 3 before_install: - - gem install bundler + - gem install bundler -v=1.11.2 before_script: - bundle update @@ -34,13 +34,6 @@ rvm: - 2.2.5 - 2.3.1 -# Railties specs on Ruby 1.8.7 are broken. -# Last recorded passing CI run is https://travis-ci.org/rails/rails/builds/48782330 -matrix: - allow_failures: - - rvm: 1.8.7 - env: GEM=railties - notifications: email: false irc: -- cgit v1.2.3 From 9b103311d5d266fa509f5da8825ea5daecba1836 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Fri, 4 Nov 2016 09:38:01 +0000 Subject: Allow time for reloading to happen Sometimes the modification time hasn't changed so the reloader doesn't pick up the changed files. This is especially true when booting the app and then modifying files. --- railties/test/application/routing_test.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/railties/test/application/routing_test.rb b/railties/test/application/routing_test.rb index 7d6033c54c..c0dba3ea3e 100644 --- a/railties/test/application/routing_test.rb +++ b/railties/test/application/routing_test.rb @@ -9,6 +9,8 @@ module ApplicationTests def setup build_app boot_rails + + sleep 1 end def teardown @@ -191,14 +193,14 @@ module ApplicationTests get '/foo' assert_equal 'bar', last_response.body + sleep 1 + app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do match 'foo', :to => 'foo#baz' end RUBY - sleep 0.1 - get '/foo' assert_equal expected, last_response.body end -- cgit v1.2.3