Code cleanup (#2369)

* Lint travis.yml on https://config.travis-ci.com/explore

* Replace deprecated 'thread_safe' with 'concurrent-ruby' alternative

'thread_safe' gem is now deprecated and merged into 'concurrent-ruby'.
Ref: 52e5f373a9 (diff-42d5a45da331eaa07d2b315bd3c9e738)

* Fix deprecation warning for Ruby 2.7

https://bugs.ruby-lang.org/issues/15539


* Remove a TODO tag that is already resolved
This commit is contained in:
Wasif Hossain 2020-01-03 08:53:59 +06:00 committed by Benjamin Fleischer
parent 6b093c965f
commit 64c7fee7a8
5 changed files with 18 additions and 17 deletions

View File

@ -1,7 +1,7 @@
language: ruby
sudo: false
os: linux
ruby_supported_versions:
_ruby_supported_versions:
- &ruby_2_1 2.1.10
- &ruby_2_2 2.2.10
- &ruby_2_3 2.3.8
@ -10,15 +10,15 @@ ruby_supported_versions:
- &ruby_2_6 2.6.5
- &ruby_head ruby-head
jruby_supported_versions:
_jruby_supported_versions:
- &jruby_9_1 jruby-9.1.17.0
- &jruby_9_2 jruby-9.2.8.0
- &jruby_head jruby-head
jdk_supported_versions:
_jdk_supported_versions:
- &jdk_8 openjdk8
rails_supported_versions:
_rails_supported_versions:
- &rails_4_1 RAILS_VERSION=4.1
- &rails_4_1_jruby RAILS_VERSION=4.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'
- &rails_4_2 RAILS_VERSION=4.2
@ -41,7 +41,7 @@ cache:
before_install:
- "travis_retry gem update --system 2.7.9"
- "travis_retry gem install bundler -v '1.17.3'"
install: BUNDLER_VERSION=1.17.3 bundle install --path=vendor/bundle --retry=3 --jobs=3
install: bundle install --path=vendor/bundle --retry=3 --jobs=3
script:
- bundle exec rake ci
@ -49,7 +49,9 @@ after_success:
- codeclimate-test-reporter
env:
matrix:
global:
- BUNDLER_VERSION=1.17.3
jobs:
- *rails_4_1
- *rails_4_2
- *rails_5_0
@ -70,7 +72,7 @@ rvm:
branches:
only: 0-10-stable
matrix:
jobs:
include:
- { rvm: *jruby_9_1, jdk: *jdk_8, env: *rails_4_1_jruby }
- { rvm: *jruby_9_1, jdk: *jdk_8, env: *rails_4_2_jruby }

View File

@ -59,5 +59,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'timecop', '~> 0.7'
spec.add_development_dependency 'grape', ['>= 0.13', '< 0.19.1']
spec.add_development_dependency 'json_schema'
spec.add_development_dependency 'rake', ['>= 10.0', '< 12.0']
spec.add_development_dependency 'rake', ['>= 10.0', '< 13.0']
end

View File

@ -73,7 +73,7 @@ module ActiveModel
# Used to cache serializer name => serializer class
# when looked up by Serializer.get_serializer_for.
def self.serializers_cache
@serializers_cache ||= ThreadSafe::Cache.new
@serializers_cache ||= Concurrent::Map.new
end
# @api private

View File

@ -87,8 +87,8 @@ module ActiveModel
# meta ids: ids
# end
# end
def link(name, value = nil)
options[:links][name] = block_given? ? Proc.new : value
def link(name, value = nil, &block)
options[:links][name] = block_given? ? block : value
:nil
end
@ -102,8 +102,8 @@ module ActiveModel
# href object.blog.id.to_s
# meta(id: object.blog.id)
# end
def meta(value = nil)
options[:meta] = block_given? ? Proc.new : value
def meta(value = nil, &block)
options[:meta] = block_given? ? block : value
:nil
end

View File

@ -35,12 +35,11 @@ module ActiveModel
class BookSerializer < ActiveModel::Serializer
attributes :title, :author_name
end
test 'resource without a namespace' do
book = Book.new(title: 'A Post', author_name: 'hello')
# TODO: this should be able to pull up this serializer without explicitly specifying the serializer
# currently, with no options, it still uses the Api::V3 serializer
result = ActiveModelSerializers::SerializableResource.new(book, serializer: BookSerializer).serializable_hash
result = ActiveModelSerializers::SerializableResource.new(book).serializable_hash
expected = { title: 'A Post', author_name: 'hello' }
assert_equal expected, result