From 5f4252f11dc277255818f44fd2a70d5508211adb Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Tue, 19 Sep 2017 08:27:52 -0500 Subject: [PATCH 01/11] Rails 5 requires explicit rails gem ``` Bundler could not find compatible versions for gem "activemodel": In Gemfile: activerecord was resolved to 5.2.0.alpha, which depends on activemodel (= 5.2.0.alpha) rails (>= 3.0) was resolved to 4.2.9, which depends on activemodel (= 4.2.9) ``` --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 476d76827..0a08db16d 100644 --- a/Gemfile +++ b/Gemfile @@ -8,6 +8,7 @@ version = ENV['RAILS_VERSION'] || '4.0' if version == 'master' gem 'rack', github: 'rack/rack' gem 'arel', github: 'rails/arel' + gem 'rails', github: 'rails/rails' git 'https://github.com/rails/rails.git' do gem 'railties' gem 'activesupport' From 9c226c67f1d1d36af80cb59808b9625701bf0bc2 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Tue, 19 Sep 2017 08:33:45 -0500 Subject: [PATCH 02/11] Rename deprecated empty ActiveModel::TestCase; removed in Rails master --- test/array_serializer_test.rb | 2 +- test/association_test.rb | 2 +- test/caching_test.rb | 2 +- test/serializer_support_test.rb | 2 +- test/serializer_test.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/array_serializer_test.rb b/test/array_serializer_test.rb index 1f2617720..fd9ffbb5f 100644 --- a/test/array_serializer_test.rb +++ b/test/array_serializer_test.rb @@ -1,7 +1,7 @@ require "test_helper" require "test_fakes" -class ArraySerializerTest < ActiveModel::TestCase +class ArraySerializerTest < ActiveSupport::TestCase def test_array_items_do_not_have_root array = [ diff --git a/test/association_test.rb b/test/association_test.rb index 2cfbd961d..c4eb121af 100644 --- a/test/association_test.rb +++ b/test/association_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class AssociationTest < ActiveModel::TestCase +class AssociationTest < ActiveSupport::TestCase def def_serializer(&block) Class.new(ActiveModel::Serializer, &block) end diff --git a/test/caching_test.rb b/test/caching_test.rb index f07f6c310..d66f2e34e 100644 --- a/test/caching_test.rb +++ b/test/caching_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class CachingTest < ActiveModel::TestCase +class CachingTest < ActiveSupport::TestCase class NullStore def fetch(key) return store[key] if store[key] diff --git a/test/serializer_support_test.rb b/test/serializer_support_test.rb index 03bd130f4..f90fa45f2 100644 --- a/test/serializer_support_test.rb +++ b/test/serializer_support_test.rb @@ -25,7 +25,7 @@ class Criteria end end -class SerializerSupportTest < ActiveModel::TestCase +class SerializerSupportTest < ActiveSupport::TestCase test "it returns nil if no serializer exists" do assert_equal nil, RandomModel.new.active_model_serializer end diff --git a/test/serializer_test.rb b/test/serializer_test.rb index 7e3e5aff9..d8695942b 100644 --- a/test/serializer_test.rb +++ b/test/serializer_test.rb @@ -1,7 +1,7 @@ require "test_helper" require "test_fakes" -class SerializerTest < ActiveModel::TestCase +class SerializerTest < ActiveSupport::TestCase def test_scope_works_correct serializer = ActiveModel::Serializer.new :foo, :scope => :bar assert_equal serializer.scope, :bar From 322c8aa59c361a63f75573952d04474a9f4ab312 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Tue, 19 Sep 2017 08:41:15 -0500 Subject: [PATCH 03/11] Rails5 requires x_action filters --- test/serialization_scope_name_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/serialization_scope_name_test.rb b/test/serialization_scope_name_test.rb index d3db103cd..e419c6310 100644 --- a/test/serialization_scope_name_test.rb +++ b/test/serialization_scope_name_test.rb @@ -14,7 +14,7 @@ def admin? class UserTestController < ActionController::Base protect_from_forgery - before_filter { request.format = :json } + before_action { request.format = :json } def current_user TestUser.new('Pete', false) @@ -47,7 +47,7 @@ class AdminUserTestController < ActionController::Base protect_from_forgery serialization_scope :current_admin - before_filter { request.format = :json } + before_action { request.format = :json } def current_admin TestUser.new('Bob', true) From ffe658f027dda4f8b09929c0f6e2e856fe5f6b8b Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Tue, 19 Sep 2017 08:43:03 -0500 Subject: [PATCH 04/11] Shim rails5 http test methods --- test/support/rails5_shims.rb | 53 ++++++++++++++++++++++++++++++++++++ test/test_helper.rb | 2 ++ 2 files changed, 55 insertions(+) create mode 100644 test/support/rails5_shims.rb diff --git a/test/support/rails5_shims.rb b/test/support/rails5_shims.rb new file mode 100644 index 000000000..03a036da6 --- /dev/null +++ b/test/support/rails5_shims.rb @@ -0,0 +1,53 @@ +module Rails5Shims + module ControllerTests + # https://github.com/rails/rails/blob/b217354/actionpack/lib/action_controller/test_case.rb + REQUEST_KWARGS = [:params, :headers, :session, :flash, :method, :body, :xhr].freeze + + def get(path, *args) + fold_kwargs!(args) + super + end + + def post(path, *args) + fold_kwargs!(args) + super + end + + def patch(path, *args) + fold_kwargs!(args) + super + end + + def put(path, *args) + fold_kwargs!(args) + super + end + + # Fold kwargs from test request into args + # Band-aid for DEPRECATION WARNING + def fold_kwargs!(args) + hash = args && args[0] + return unless hash.respond_to?(:key) + Rails5Shims::ControllerTests::REQUEST_KWARGS.each do |kwarg| + next unless hash.key?(kwarg) + value = hash.delete(kwarg) + if value.is_a? String + args.insert(0, value) + else + hash.merge! value + end + end + end + + # Uncomment for debugging where the kwargs warnings come from + # def non_kwarg_request_warning + # super.tap do + # STDOUT.puts caller[2..3] + # end + # end + end +end +if Rails::VERSION::MAJOR < 5 + ActionController::TestCase.send :include, Rails5Shims::ControllerTests + ActionDispatch::IntegrationTest.send :include, Rails5Shims::ControllerTests +end diff --git a/test/test_helper.rb b/test/test_helper.rb index b7b3f2e9e..061f64fae 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -53,3 +53,5 @@ module TestHelper class Object undef_method :id if respond_to?(:id) end + +require "support/rails5_shims" From aabc1cb07d2b53c80c658aa52f807d50ac8868ee Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Thu, 2 Nov 2017 08:49:04 -0500 Subject: [PATCH 05/11] Remove rubinius tests, too fragile --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fd7f58df3..69083f286 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ rvm: - 2.0.0 - 2.1 - 2.2 - - rbx-2 install: bundle install --path=vendor/bundle --retry=3 --jobs=3 cache: directories: From 37d4bdc4d2cad98137fd6f9b6bbed64dd40d5203 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Thu, 2 Nov 2017 08:53:07 -0500 Subject: [PATCH 06/11] Address bundle not finding actionpack via dep require order --- Gemfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 0a08db16d..5138cfb0f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,5 @@ source 'https://rubygems.org' -# Specify gem dependencies in active_model_serializers.gemspec -gemspec - version = ENV['RAILS_VERSION'] || '4.0' if version == 'master' @@ -27,6 +24,9 @@ else gem 'activerecord', gem_version, group: :test end +# Specify gem dependencies in active_model_serializers.gemspec +gemspec + # https://github.com/bundler/bundler/blob/89a8778c19269561926cea172acdcda241d26d23/lib/bundler/dependency.rb#L30-L54 @windows_platforms = [:mswin, :mingw, :x64_mingw] From f2c874121950be7d3bbf849ff323ef5b4b58d625 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Thu, 2 Nov 2017 09:11:57 -0500 Subject: [PATCH 07/11] Specify rails gem for pre rails master https://ci.appveyor.com/project/bf4/active-model-serializers/build/1144/job/rf3yi4b7vf8w4t6l ``` Build started git clone -q --branch=fix_ci https://github.com/rails-api/active_model_serializers.git C:\projects\active-model-serializers git checkout -qf 37d4bdc4d2cad98137fd6f9b6bbed64dd40d5203 Running Install scripts SET PATH=C:\Ruby%ruby_version%\bin;%PATH% ruby --version ruby 2.0.0p648 (2015-12-16) [i386-mingw32] gem --version 2.6.13 gem install bundler Successfully installed bundler-1.16.0 Parsing documentation for bundler-1.16.0 Installing ri documentation for bundler-1.16.0 1 gem installed bundler --version Bundler version 1.16.0 bundle platform Your platform is: i386-mingw32 Your app has gems that work on these platforms: * x86-mingw32 Your Gemfile does not specify a Ruby version requirement. bundle install --path=vendor/bundle --retry=3 --jobs=3 Fetching gem metadata from https://rubygems.org/.......... Fetching gem metadata from https://rubygems.org/. Resolving dependencies........................................... Bundler could not find compatible versions for gem "actionpack": In Gemfile: actionpack (~> 4.0.0) x86-mingw32 Could not find gem 'actionpack (~> 4.0.0)' in any of the sources. Bundler could not find compatible versions for gem "activemodel": In Gemfile: activemodel (~> 4.0.0) x86-mingw32 active_model_serializers x86-mingw32 was resolved to 0.8.4, which depends on activemodel (>= 3.0) x86-mingw32 activerecord (~> 4.0.0) x86-mingw32 was resolved to 4.0.0, which depends on activemodel (= 4.0.0) x86-mingw32 Bundler could not find compatible versions for gem "activesupport": In Gemfile: activesupport (~> 4.0.0) x86-mingw32 actionpack (~> 4.0.0) x86-mingw32 was resolved to 4.0.0, which depends on activesupport (= 4.0.0) x86-mingw32 Bundler could not find compatible versions for gem "ruby": In Gemfile: ruby x86-mingw32 pry x86-mingw32 was resolved to 0.11.2, which depends on ruby (>= 1.9.3) x86-mingw32 rails (>= 3.0) x86-mingw32 was resolved to 5.1.4, which depends on ruby (>= 2.2.2) x86-mingw32 Bundler could not find compatible versions for gem "tzinfo": In Gemfile: actionpack (~> 4.0.0) x86-mingw32 was resolved to 4.0.0, which depends on activesupport (= 4.0.0) x86-mingw32 was resolved to 4.0.0, which depends on tzinfo (~> 0.3.37) x86-mingw32 tzinfo-data x86-mingw32 was resolved to 1.2017.3, which depends on tzinfo (>= 1.0.0) x86-mingw32 Command exited with code 6 ``` --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 5138cfb0f..02d6307db 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,7 @@ if version == 'master' end else gem_version = "~> #{version}.0" + gem 'rails', gem_version gem 'railties', gem_version gem 'activesupport', gem_version gem 'activemodel', gem_version From 2e2cdc91e0706eda2b5e20d40655ccf2f01d9c20 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Thu, 2 Nov 2017 09:20:55 -0500 Subject: [PATCH 08/11] Turn off Rails 4.0 temporarily --- .travis.yml | 2 +- Gemfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 69083f286..71cd24bfa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ env: # - "RAILS_VERSION=3.0" # - "RAILS_VERSION=3.1" # - "RAILS_VERSION=3.2" - - "RAILS_VERSION=4.0" + # - "RAILS_VERSION=4.0" - "RAILS_VERSION=4.1" - "RAILS_VERSION=4.2" # - "RAILS_VERSION=master" diff --git a/Gemfile b/Gemfile index 02d6307db..19df052b2 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -version = ENV['RAILS_VERSION'] || '4.0' +version = ENV['RAILS_VERSION'] || '4.1' if version == 'master' gem 'rack', github: 'rack/rack' From b2b3112110caa8afe5e1296cd5357433abcf97b6 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Thu, 2 Nov 2017 09:19:40 -0500 Subject: [PATCH 09/11] Advice from rails/rails --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 19df052b2..384d7c261 100644 --- a/Gemfile +++ b/Gemfile @@ -29,7 +29,7 @@ end gemspec # https://github.com/bundler/bundler/blob/89a8778c19269561926cea172acdcda241d26d23/lib/bundler/dependency.rb#L30-L54 -@windows_platforms = [:mswin, :mingw, :x64_mingw] +@windows_platforms = [:mswin, :mswin64, :mingw, :x64_mingw] # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: (@windows_platforms + [:jruby]) From c92a08a94a2ae0e1e9debfc106db753bb54d794b Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Thu, 2 Nov 2017 10:09:09 -0500 Subject: [PATCH 10/11] Re-enable Rails 4.0 non-windows --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 71cd24bfa..69083f286 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ env: # - "RAILS_VERSION=3.0" # - "RAILS_VERSION=3.1" # - "RAILS_VERSION=3.2" - # - "RAILS_VERSION=4.0" + - "RAILS_VERSION=4.0" - "RAILS_VERSION=4.1" - "RAILS_VERSION=4.2" # - "RAILS_VERSION=master" From bba131759a8b5ab27d66894f720c246ba07148e2 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Thu, 2 Nov 2017 11:25:07 -0500 Subject: [PATCH 11/11] Turn of JRuby CI on Rails 4.0 https://travis-ci.org/rails-api/active_model_serializers/jobs/296314721 ``` Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m jruby: warning: unknown property jruby.cext.enabled 2.7.0 32.06s$ bundle install --path=vendor/bundle --retry=3 --jobs=3 Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m jruby: warning: unknown property jruby.cext.enabled Fetching gem metadata from https://rubygems.org/.......... Fetching gem metadata from https://rubygems.org/. Resolving dependencies......................................................................................................................... Bundler could not find compatible versions for gem "actionpack": In Gemfile: actionpack (~> 4.0.0) java rails (~> 4.0.0) java was resolved to 4.0.0, which depends on actionpack (= 4.0.0) java Bundler could not find compatible versions for gem "activemodel": In Gemfile: activemodel (~> 4.0.0) java active_model_serializers java was resolved to 0.8.4, which depends on activemodel (>= 3.0) java rails (~> 4.0.0) java was resolved to 4.0.0, which depends on activerecord (= 4.0.0) java was resolved to 4.0.0, which depends on activemodel (= 4.0.0) java Bundler could not find compatible versions for gem "activerecord": In Gemfile: activerecord (~> 4.0.0) java rails (~> 4.0.0) java was resolved to 4.0.0, which depends on activerecord (= 4.0.0) java Bundler could not find compatible versions for gem "activesupport": In Gemfile: activesupport (~> 4.0.0) java rails (~> 4.0.0) java was resolved to 4.0.0, which depends on activesupport (= 4.0.0) java Bundler could not find compatible versions for gem "rails": In Gemfile: rails (~> 4.0.0) java Could not find gem 'rails (~> 4.0.0)' in any of the sources. Bundler could not find compatible versions for gem "railties": In Gemfile: railties (~> 4.0.0) java rails (~> 4.0.0) java was resolved to 4.0.0, which depends on railties (= 4.0.0) java Bundler could not find compatible versions for gem "tzinfo": In Gemfile: rails (~> 4.0.0) java was resolved to 4.0.0, which depends on activesupport (= 4.0.0) java was resolved to 4.0.0, which depends on tzinfo (~> 0.3.37) java tzinfo-data java was resolved to 1.2017.3, which depends on tzinfo (>= 1.0.0) java The command "bundle install --path=vendor/bundle --retry=3 --jobs=3" failed and exited with 6 during . Your build has been stopped. ``` --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 69083f286..a391e3ddf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,8 @@ env: # - "RAILS_VERSION=master" matrix: exclude: + - rvm: jruby-19mode + env: "RAILS_VERSION=4.0" # - rvm: 1.8.7 # - ree # - jruby-18mode