mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Merge pull request #1662 from remear/drop-old-versions
Drop support for Rails 4.0 and Ruby 2.0.0
This commit is contained in:
commit
74d172b4f6
@ -3,7 +3,6 @@ language: ruby
|
|||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
rvm:
|
rvm:
|
||||||
- 2.0.0
|
|
||||||
- 2.1
|
- 2.1
|
||||||
- 2.2.3
|
- 2.2.3
|
||||||
- 2.3.0
|
- 2.3.0
|
||||||
@ -26,25 +25,18 @@ env:
|
|||||||
global:
|
global:
|
||||||
- "JRUBY_OPTS='--dev -J-Xmx1024M --debug'"
|
- "JRUBY_OPTS='--dev -J-Xmx1024M --debug'"
|
||||||
matrix:
|
matrix:
|
||||||
- "RAILS_VERSION=4.0"
|
|
||||||
- "RAILS_VERSION=4.1"
|
- "RAILS_VERSION=4.1"
|
||||||
- "RAILS_VERSION=4.2"
|
- "RAILS_VERSION=4.2"
|
||||||
- "RAILS_VERSION=master"
|
- "RAILS_VERSION=master"
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
exclude:
|
exclude:
|
||||||
- rvm: 2.0.0
|
|
||||||
env: RAILS_VERSION=master
|
|
||||||
- rvm: 2.1
|
- rvm: 2.1
|
||||||
env: RAILS_VERSION=master
|
env: RAILS_VERSION=master
|
||||||
- rvm: jruby-9.0.4.0
|
- rvm: jruby-9.0.4.0
|
||||||
env: RAILS_VERSION=master
|
env: RAILS_VERSION=master
|
||||||
- rvm: jruby-9.0.4.0
|
|
||||||
env: RAILS_VERSION=4.0
|
|
||||||
- rvm: jruby-head
|
- rvm: jruby-head
|
||||||
env: RAILS_VERSION=master
|
env: RAILS_VERSION=master
|
||||||
- rvm: jruby-head
|
|
||||||
env: RAILS_VERSION=4.0
|
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- rvm: ruby-head
|
- rvm: ruby-head
|
||||||
- rvm: jruby-head
|
- rvm: jruby-head
|
||||||
|
|||||||
1
Gemfile
1
Gemfile
@ -44,7 +44,6 @@ end
|
|||||||
group :test do
|
group :test do
|
||||||
gem 'sqlite3', platform: (@windows_platforms + [:ruby])
|
gem 'sqlite3', platform: (@windows_platforms + [:ruby])
|
||||||
gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
|
gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
|
||||||
|
|
||||||
gem 'codeclimate-test-reporter', require: false
|
gem 'codeclimate-test-reporter', require: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -4,8 +4,6 @@ skip_tags: true
|
|||||||
|
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- ruby_version: "200"
|
|
||||||
- ruby_version: "200-x64"
|
|
||||||
- ruby_version: "21"
|
- ruby_version: "21"
|
||||||
- ruby_version: "21-x64"
|
- ruby_version: "21-x64"
|
||||||
- ruby_version: "jruby-9.0.4.0"
|
- ruby_version: "jruby-9.0.4.0"
|
||||||
|
|||||||
@ -76,20 +76,17 @@ module ActiveModel::Serializer::Lint
|
|||||||
resource.to_json(nil)
|
resource.to_json(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Passes if the object responds to <tt>cache_key</tt> and if it takes no
|
# Passes if the object responds to <tt>cache_key</tt>
|
||||||
# arguments (Rails 4.0) or a splat (Rails 4.1+).
|
|
||||||
# Fails otherwise.
|
# Fails otherwise.
|
||||||
#
|
#
|
||||||
# <tt>cache_key</tt> returns a (self-expiring) unique key for the object, and
|
# <tt>cache_key</tt> returns a (self-expiring) unique key for the object,
|
||||||
# is part of the (self-expiring) cache_key, which is used by the adapter.
|
# and is part of the (self-expiring) cache_key, which is used by the
|
||||||
# It is not required unless caching is enabled.
|
# adapter. It is not required unless caching is enabled.
|
||||||
def test_cache_key
|
def test_cache_key
|
||||||
assert_respond_to resource, :cache_key
|
assert_respond_to resource, :cache_key
|
||||||
actual_arity = resource.method(:cache_key).arity
|
actual_arity = resource.method(:cache_key).arity
|
||||||
# using absolute value since arity is:
|
assert_includes [-1, 0], actual_arity,
|
||||||
# 0 for Rails 4.1+, *timestamp_names
|
"expected #{actual_arity.inspect} to be 0 or -1"
|
||||||
# -1 for Rails 4.0, no arguments
|
|
||||||
assert_includes [-1, 0], actual_arity, "expected #{actual_arity.inspect} to be 0 or -1"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Passes if the object responds to <tt>updated_at</tt> and if it takes no
|
# Passes if the object responds to <tt>updated_at</tt> and if it takes no
|
||||||
|
|||||||
@ -10,9 +10,8 @@ module ActiveModelSerializers
|
|||||||
render json: Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
|
render json: Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
|
||||||
end
|
end
|
||||||
|
|
||||||
# For Rails4.0
|
|
||||||
def render_some_text
|
def render_some_text
|
||||||
Rails.version > '4.1' ? render(plain: 'ok') : render(text: 'ok')
|
render(plain: 'ok')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -3,34 +3,19 @@ require_relative 'collection_serializer_test'
|
|||||||
|
|
||||||
module ActiveModel
|
module ActiveModel
|
||||||
class Serializer
|
class Serializer
|
||||||
# Minitest.run_one_method isn't present in minitest 4
|
class ArraySerializerTest < CollectionSerializerTest
|
||||||
if $minitest_version > 4 # rubocop:disable Style/GlobalVars
|
extend Minitest::Assertions
|
||||||
class ArraySerializerTest < CollectionSerializerTest
|
def self.run_one_method(*)
|
||||||
extend Minitest::Assertions
|
_, stderr = capture_io do
|
||||||
def self.run_one_method(*)
|
super
|
||||||
_, stderr = capture_io do
|
|
||||||
super
|
|
||||||
end
|
|
||||||
if stderr !~ /NOTE: ActiveModel::Serializer::ArraySerializer.new is deprecated/
|
|
||||||
fail Minitest::Assertion, stderr
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
if stderr !~ /NOTE: ActiveModel::Serializer::ArraySerializer.new is deprecated/
|
||||||
def collection_serializer
|
fail Minitest::Assertion, stderr
|
||||||
ArraySerializer
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
class ArraySerializerTest < ActiveSupport::TestCase
|
def collection_serializer
|
||||||
def test_json_key_with_root_warns_when_using_array_serializer
|
ArraySerializer
|
||||||
_, stderr = capture_io do
|
|
||||||
comment = Comment.new
|
|
||||||
post = Post.new
|
|
||||||
serializer = ArraySerializer.new([comment, post])
|
|
||||||
assert_equal 'comments', serializer.json_key
|
|
||||||
end
|
|
||||||
assert_match(/NOTE: ActiveModel::Serializer::ArraySerializer.new is deprecated/, stderr)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -19,27 +19,9 @@ require 'fileutils'
|
|||||||
FileUtils.mkdir_p(File.expand_path('../../tmp/cache', __FILE__))
|
FileUtils.mkdir_p(File.expand_path('../../tmp/cache', __FILE__))
|
||||||
|
|
||||||
gem 'minitest'
|
gem 'minitest'
|
||||||
begin
|
require 'minitest'
|
||||||
require 'minitest'
|
require 'minitest/autorun'
|
||||||
rescue LoadError
|
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
||||||
# Minitest 4
|
|
||||||
require 'minitest/autorun'
|
|
||||||
$minitest_version = 4
|
|
||||||
# https://github.com/seattlerb/minitest/blob/644a52fd0/lib/minitest/autorun.rb
|
|
||||||
# https://github.com/seattlerb/minitest/blob/644a52fd0/lib/minitest/unit.rb#L768-L787
|
|
||||||
# Ensure backward compatibility with Minitest 4
|
|
||||||
Minitest = MiniTest unless defined?(Minitest)
|
|
||||||
Minitest::Test = MiniTest::Unit::TestCase
|
|
||||||
else
|
|
||||||
# Minitest 5
|
|
||||||
require 'minitest/autorun'
|
|
||||||
$minitest_version = 5
|
|
||||||
# https://github.com/seattlerb/minitest/blob/e21fdda9d/lib/minitest/autorun.rb
|
|
||||||
# https://github.com/seattlerb/minitest/blob/e21fdda9d/lib/minitest.rb#L45-L59
|
|
||||||
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
|
||||||
# to be shown.
|
|
||||||
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
|
||||||
end
|
|
||||||
|
|
||||||
require 'support/rails_app'
|
require 'support/rails_app'
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user