diff --git a/.travis.yml b/.travis.yml index fd7f58df3..a391e3ddf 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: @@ -27,6 +26,8 @@ env: # - "RAILS_VERSION=master" matrix: exclude: + - rvm: jruby-19mode + env: "RAILS_VERSION=4.0" # - rvm: 1.8.7 # - ree # - jruby-18mode diff --git a/Gemfile b/Gemfile index 476d76827..384d7c261 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,11 @@ source 'https://rubygems.org' -# Specify gem dependencies in active_model_serializers.gemspec -gemspec - -version = ENV['RAILS_VERSION'] || '4.0' +version = ENV['RAILS_VERSION'] || '4.1' 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' @@ -19,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 @@ -26,8 +25,11 @@ 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] +@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]) 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/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) 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 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"