mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Merge pull request #1323 from bf4/fix_deprecations_config
Use Minitest::Reporters to capture warnings && show error output
This commit is contained in:
commit
03653032c5
@ -8,7 +8,6 @@ cache:
|
|||||||
rvm:
|
rvm:
|
||||||
- 1.9.3
|
- 1.9.3
|
||||||
- 2.0.0
|
- 2.0.0
|
||||||
- 2.1
|
|
||||||
- 2.2
|
- 2.2
|
||||||
- ruby-head
|
- ruby-head
|
||||||
- rbx-2
|
- rbx-2
|
||||||
@ -17,7 +16,7 @@ install:
|
|||||||
- bundle install --retry=3
|
- bundle install --retry=3
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- env CAPTURE_STDERR=false bundle exec rake ci
|
- env CAPTURE_STDERR=${CAPTURE_STDERR:-false} bundle exec rake ci
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- "RAILS_VERSION=4.0"
|
- "RAILS_VERSION=4.0"
|
||||||
@ -27,6 +26,8 @@ env:
|
|||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
|
- rvm: 2.1
|
||||||
|
env: CAPTURE_STDERR=true
|
||||||
- rvm: jruby-19mode
|
- rvm: jruby-19mode
|
||||||
env: JRUBY_OPTS='--server -Xcompile.invokedynamic=false -Xcli.debug=true --debug'
|
env: JRUBY_OPTS='--server -Xcompile.invokedynamic=false -Xcli.debug=true --debug'
|
||||||
allow_failures:
|
allow_failures:
|
||||||
|
|||||||
@ -2,7 +2,7 @@ require 'active_model/serializer/collection_serializer'
|
|||||||
class ActiveModel::Serializer
|
class ActiveModel::Serializer
|
||||||
class ArraySerializer < CollectionSerializer
|
class ArraySerializer < CollectionSerializer
|
||||||
def initialize(*)
|
def initialize(*)
|
||||||
warn "Calling deprecated ArraySerializer in #{caller[0]}. Please use CollectionSerializer"
|
warn "Calling deprecated ArraySerializer in #{caller[0..2].join(', ')}. Please use CollectionSerializer"
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,6 +3,8 @@ require_relative 'collection_serializer_test'
|
|||||||
|
|
||||||
module ActiveModel
|
module ActiveModel
|
||||||
class Serializer
|
class Serializer
|
||||||
|
# Minitest.run_one_method isn't present in minitest 4
|
||||||
|
if $minitest_version > 4 # rubocop:disable Style/GlobalVars
|
||||||
class ArraySerializerTest < CollectionSerializerTest
|
class ArraySerializerTest < CollectionSerializerTest
|
||||||
extend ActiveSupport::Testing::Stream
|
extend ActiveSupport::Testing::Stream
|
||||||
def self.run_one_method(*)
|
def self.run_one_method(*)
|
||||||
@ -18,5 +20,19 @@ module ActiveModel
|
|||||||
ArraySerializer
|
ArraySerializer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
class ArraySerializerTest < Minitest::Test
|
||||||
|
extend ActiveSupport::Testing::Stream
|
||||||
|
def test_json_key_with_root_warns_when_using_array_serializer
|
||||||
|
stderr = (capture(:stderr) do
|
||||||
|
comment = Comment.new
|
||||||
|
post = Post.new
|
||||||
|
serializer = ArraySerializer.new([comment, post])
|
||||||
|
assert_equal serializer.json_key, 'comments'
|
||||||
|
end)
|
||||||
|
assert_match(/Calling deprecated ArraySerializer/, stderr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -25,10 +25,12 @@ require 'minitest/autorun'
|
|||||||
require 'minitest/reporters'
|
require 'minitest/reporters'
|
||||||
Minitest::Reporters.use!
|
Minitest::Reporters.use!
|
||||||
if defined?(Minitest::Test)
|
if defined?(Minitest::Test)
|
||||||
|
$minitest_version = 5 # rubocop:disable Style/GlobalVars
|
||||||
# Minitest 5
|
# Minitest 5
|
||||||
# https://github.com/seattlerb/minitest/blob/e21fdda9d/lib/minitest/autorun.rb
|
# https://github.com/seattlerb/minitest/blob/e21fdda9d/lib/minitest/autorun.rb
|
||||||
# https://github.com/seattlerb/minitest/blob/e21fdda9d/lib/minitest.rb#L45-L59
|
# https://github.com/seattlerb/minitest/blob/e21fdda9d/lib/minitest.rb#L45-L59
|
||||||
else
|
else
|
||||||
|
$minitest_version = 4 # rubocop:disable Style/GlobalVars
|
||||||
# Minitest 4
|
# Minitest 4
|
||||||
# https://github.com/seattlerb/minitest/blob/644a52fd0/lib/minitest/autorun.rb
|
# https://github.com/seattlerb/minitest/blob/644a52fd0/lib/minitest/autorun.rb
|
||||||
# https://github.com/seattlerb/minitest/blob/644a52fd0/lib/minitest/unit.rb#L768-L787
|
# https://github.com/seattlerb/minitest/blob/644a52fd0/lib/minitest/unit.rb#L768-L787
|
||||||
@ -47,6 +49,8 @@ end
|
|||||||
if ENV['CAPTURE_STDERR'] !~ /false|1/i
|
if ENV['CAPTURE_STDERR'] !~ /false|1/i
|
||||||
require 'capture_warnings'
|
require 'capture_warnings'
|
||||||
CaptureWarnings.new(_fail_build = true).execute!
|
CaptureWarnings.new(_fail_build = true).execute!
|
||||||
|
else
|
||||||
|
$VERBOSE = true
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'active_model_serializers'
|
require 'active_model_serializers'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user