From 0aa1ed93a49c06c7c19a5d4fec0afe9cf52c35b4 Mon Sep 17 00:00:00 2001 From: Wasif Hossain Date: Mon, 22 Apr 2019 23:22:28 +0600 Subject: [PATCH 1/3] Configure sqlite3 to use ~> 1.4 for rails 6+ --- Gemfile | 8 +++++++- test/support/ruby_2_6_rails_4_2_patch.rb | 16 ++++++++++++++++ test/test_helper.rb | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/support/ruby_2_6_rails_4_2_patch.rb diff --git a/Gemfile b/Gemfile index 59f77c9d..dd3185b6 100644 --- a/Gemfile +++ b/Gemfile @@ -53,7 +53,13 @@ group :bench do end group :test do - gem 'sqlite3', '~> 1.3.13', platform: (@windows_platforms + [:ruby]) + platforms *(@windows_platforms + [:ruby]) do + if version == 'master' || version >= '6' + gem 'sqlite3', '~> 1.4' + else + gem 'sqlite3', '~> 1.3.13' + end + end platforms :jruby do if version == 'master' || version >= '5' gem 'activerecord-jdbcsqlite3-adapter', '~> 50' diff --git a/test/support/ruby_2_6_rails_4_2_patch.rb b/test/support/ruby_2_6_rails_4_2_patch.rb new file mode 100644 index 00000000..e4de2432 --- /dev/null +++ b/test/support/ruby_2_6_rails_4_2_patch.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +if RUBY_VERSION >= '2.6.0' + if Rails::VERSION::MAJOR < 5 + class ActionController::TestResponse < ActionDispatch::TestResponse + def recycle! + # hack to avoid MonitorMixin double-initialize error: + @mon_mutex_owner_object_id = nil + @mon_mutex = nil + initialize + end + end + else + puts "Monkeypatch for ActionController::TestResponse no longer needed" + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 80996494..e8f60cc9 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -56,6 +56,8 @@ end require 'support/rails_app' +require 'support/ruby_2_6_rails_4_2_patch' + # require "rails/test_help" require 'support/serialization_testing' From 3715a101c20127059d305bc8cd5fe10d6da22733 Mon Sep 17 00:00:00 2001 From: Wasif Hossain Date: Tue, 23 Apr 2019 01:42:21 +0600 Subject: [PATCH 2/3] Refactor travis.yml --- .travis.yml | 60 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index 609035d4..8343c3e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,15 @@ language: ruby sudo: false +ruby_supported_versions: + - &ruby_2_1 2.1.10 + - &ruby_2_2 2.2.10 + - &ruby_2_3 2.3.8 + - &ruby_2_4 2.4.6 + - &ruby_2_5 2.5.5 + - &ruby_2_6 2.6.3 + - &ruby_head ruby-head + cache: directories: - vendor/bundle @@ -25,38 +34,39 @@ env: - "RAILS_VERSION=master" rvm: - - 2.1.10 - - 2.2.8 - - 2.3.5 - - 2.4.2 - - 2.5.3 - - ruby-head + - *ruby_2_1 + - *ruby_2_2 + - *ruby_2_3 + - *ruby_2_4 + - *ruby_2_5 + - *ruby_2_6 + - *ruby_head branches: - only: - - 0-10-stable + only: 0-10-stable matrix: include: - - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } - - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.2 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } - - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } - # See JRuby currently failing on Rails 5+ https://github.com/jruby/activerecord-jdbc-adapter/issues/708 - # - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.0 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } - # - { rvm: jruby-head, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } + - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } + - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.2 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } + - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } + # See JRuby currently failing on Rails 5+ https://github.com/jruby/activerecord-jdbc-adapter/issues/708 + # - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.0 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } + # - { rvm: jruby-head, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } exclude: - - { rvm: 2.1.10, env: RAILS_VERSION=master } - - { rvm: 2.2.8, env: RAILS_VERSION=master } - - { rvm: 2.3.5, env: RAILS_VERSION=master } - - { rvm: 2.4.2, env: RAILS_VERSION=master } - - { rvm: 2.1.10, env: RAILS_VERSION=5.0 } - - { rvm: 2.1.10, env: RAILS_VERSION=5.1 } - - { rvm: 2.1.10, env: RAILS_VERSION=5.2 } - - { rvm: 2.4.2, env: RAILS_VERSION=4.1 } - - { rvm: 2.5.3, env: RAILS_VERSION=4.1 } - - { rvm: ruby-head, env: RAILS_VERSION=4.1 } + - { rvm: *ruby_2_4, env: RAILS_VERSION=master } + - { rvm: *ruby_2_3, env: RAILS_VERSION=master } + - { rvm: *ruby_2_2, env: RAILS_VERSION=master } + - { rvm: *ruby_2_1, env: RAILS_VERSION=master } + - { rvm: *ruby_2_1, env: RAILS_VERSION=5.2 } + - { rvm: *ruby_2_1, env: RAILS_VERSION=5.1 } + - { rvm: *ruby_2_1, env: RAILS_VERSION=5.0 } + - { rvm: *ruby_head, env: RAILS_VERSION=4.1 } + - { rvm: *ruby_2_6, env: RAILS_VERSION=4.1 } + - { rvm: *ruby_2_5, env: RAILS_VERSION=4.1 } + - { rvm: *ruby_2_4, env: RAILS_VERSION=4.1 } allow_failures: - - rvm: ruby-head + - rvm: *ruby_head - rvm: jruby-head # See JRuby currently failing on Rails 5+ https://github.com/jruby/activerecord-jdbc-adapter/issues/708 - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } From 5d122f292231d3a38e6e9c623a60721a8e0de3cc Mon Sep 17 00:00:00 2001 From: Wasif Hossain Date: Tue, 23 Apr 2019 02:06:12 +0600 Subject: [PATCH 3/3] Fix rubocop offenses --- Gemfile | 4 ++-- test/benchmark/config.ru | 2 ++ test/support/ruby_2_6_rails_4_2_patch.rb | 16 +++++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index dd3185b6..dc08274e 100644 --- a/Gemfile +++ b/Gemfile @@ -53,7 +53,7 @@ group :bench do end group :test do - platforms *(@windows_platforms + [:ruby]) do + platforms(*(@windows_platforms + [:ruby])) do if version == 'master' || version >= '6' gem 'sqlite3', '~> 1.4' else @@ -71,7 +71,7 @@ group :test do gem 'm', '~> 1.5' gem 'pry', '>= 0.10' gem 'byebug', '~> 8.2' if RUBY_VERSION < '2.2' - gem 'pry-byebug', platform: :ruby + gem 'pry-byebug', platforms: :ruby end group :development, :test do diff --git a/test/benchmark/config.ru b/test/benchmark/config.ru index 908eb28c..7b0654bb 100644 --- a/test/benchmark/config.ru +++ b/test/benchmark/config.ru @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require File.expand_path(['..', 'app'].join(File::SEPARATOR), __FILE__) run Rails.application diff --git a/test/support/ruby_2_6_rails_4_2_patch.rb b/test/support/ruby_2_6_rails_4_2_patch.rb index e4de2432..9e250339 100644 --- a/test/support/ruby_2_6_rails_4_2_patch.rb +++ b/test/support/ruby_2_6_rails_4_2_patch.rb @@ -2,15 +2,17 @@ if RUBY_VERSION >= '2.6.0' if Rails::VERSION::MAJOR < 5 - class ActionController::TestResponse < ActionDispatch::TestResponse - def recycle! - # hack to avoid MonitorMixin double-initialize error: - @mon_mutex_owner_object_id = nil - @mon_mutex = nil - initialize + module ActionController + class TestResponse < ActionDispatch::TestResponse + def recycle! + # HACK: to avoid MonitorMixin double-initialize error: + @mon_mutex_owner_object_id = nil + @mon_mutex = nil + initialize + end end end else - puts "Monkeypatch for ActionController::TestResponse no longer needed" + puts 'Monkeypatch for ActionController::TestResponse no longer needed' end end