mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Merge pull request #2196 from rails-api/fix_ci
Fix CI for 0.8.x for Rails 5/master
This commit is contained in:
commit
0ef0f0c538
@ -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
|
||||
|
||||
12
Gemfile
12
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])
|
||||
|
||||
@ -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 = [
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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]
|
||||
|
||||
@ -14,7 +14,7 @@ class DefaultScopeNameTest < ActionController::TestCase
|
||||
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 SerializationScopeNameTest < ActionController::TestCase
|
||||
protect_from_forgery
|
||||
|
||||
serialization_scope :current_admin
|
||||
before_filter { request.format = :json }
|
||||
before_action { request.format = :json }
|
||||
|
||||
def current_admin
|
||||
TestUser.new('Bob', true)
|
||||
|
||||
@ -25,7 +25,7 @@ module Mongoid
|
||||
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
|
||||
|
||||
@ -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
|
||||
|
||||
53
test/support/rails5_shims.rb
Normal file
53
test/support/rails5_shims.rb
Normal file
@ -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
|
||||
@ -53,3 +53,5 @@ end
|
||||
class Object
|
||||
undef_method :id if respond_to?(:id)
|
||||
end
|
||||
|
||||
require "support/rails5_shims"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user