Skip to content

Commit a748e56

Browse files
authored
Merge branch '0-10-stable' into fix-next-links-for-out-of-bounds-pages
2 parents de6c30c + 4d7c245 commit a748e56

File tree

11 files changed

+64
-45
lines changed

11 files changed

+64
-45
lines changed

.travis.yml

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,52 @@
11
language: ruby
2-
32
sudo: false
43

5-
rvm:
6-
- 2.1
7-
- 2.2.6
8-
- 2.3.3
9-
- ruby-head
10-
- jruby-9.1.5.0 # is precompiled per http://rubies.travis-ci.org/
11-
- jruby-head
12-
13-
jdk:
14-
- oraclejdk8
15-
16-
before_install:
17-
- gem update --system
18-
- rvm @global do gem uninstall bundler -a -x
19-
- rvm @global do gem install bundler -v 1.13.7
20-
install: bundle install --path=vendor/bundle --retry=3 --jobs=3
214
cache:
225
directories:
236
- vendor/bundle
247

8+
before_install:
9+
- "travis_retry gem update --system"
10+
- "travis_retry gem update bundler"
11+
install: bundle install --path=vendor/bundle --retry=3 --jobs=3
12+
2513
script:
2614
- bundle exec rake ci
2715
after_success:
2816
- codeclimate-test-reporter
17+
2918
env:
30-
global:
31-
- "JRUBY_OPTS='--dev -J-Xmx1024M --debug'"
3219
matrix:
3320
- "RAILS_VERSION=4.1"
3421
- "RAILS_VERSION=4.2"
3522
- "RAILS_VERSION=5.0"
23+
- "RAILS_VERSION=5.1"
3624
- "RAILS_VERSION=master"
3725

26+
rvm:
27+
- 2.1.10
28+
- 2.2.8
29+
- 2.3.5
30+
- 2.4.2
31+
- ruby-head
32+
3833
matrix:
34+
include:
35+
- { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
36+
- { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.2 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
37+
- { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
38+
# See JRuby currently failing on Rails 5+ https://github.com/jruby/activerecord-jdbc-adapter/issues/708
39+
# - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.0 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
40+
# - { rvm: jruby-head, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
3941
exclude:
40-
- rvm: 2.1
41-
env: RAILS_VERSION=master
42-
- rvm: jruby-9.1.5.0
43-
env: RAILS_VERSION=master
44-
- rvm: jruby-head
45-
env: RAILS_VERSION=master
46-
- rvm: 2.1
47-
env: RAILS_VERSION=5.0
48-
- rvm: jruby-9.1.5.0
49-
env: RAILS_VERSION=5.0
50-
- rvm: jruby-head
51-
env: RAILS_VERSION=5.0
42+
- { rvm: 2.1.10, env: RAILS_VERSION=master }
43+
- { rvm: 2.1.10, env: RAILS_VERSION=5.0 }
44+
- { rvm: 2.1.10, env: RAILS_VERSION=5.1 }
45+
- { rvm: 2.4.2, env: RAILS_VERSION=4.1 }
46+
- { rvm: ruby-head, env: RAILS_VERSION=4.1 }
5247
allow_failures:
5348
- rvm: ruby-head
5449
- rvm: jruby-head
50+
# See JRuby currently failing on Rails 5+ https://github.com/jruby/activerecord-jdbc-adapter/issues/708
51+
- { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
5552
fast_finish: true

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ Features:
99

1010
- [#2021](https://github.com/rails-api/active_model_serializers/pull/2021) ActiveModelSerializers::Model#attributes. Originally in [#1982](https://github.com/rails-api/active_model_serializers/pull/1982). (@bf4)
1111
- [#2130](https://github.com/rails-api/active_model_serializers/pull/2130) Allow serialized ID to be overwritten for belongs-to relationships. (@greysteil)
12+
- [#2189](https://github.com/rails-api/active_model_serializers/pull/2189)
13+
Update version constraint for jsonapi-renderer to `['>= 0.1.1.beta1', '< 0.3']`
14+
(@tagliala)
1215

1316
Fixes:
1417

1518
- [#2022](https://github.com/rails-api/active_model_serializers/pull/2022) Mutation of ActiveModelSerializers::Model now changes the attributes. Originally in [#1984](https://github.com/rails-api/active_model_serializers/pull/1984). (@bf4)
1619
- [#2171](https://github.com/rails-api/active_model_serializers/pull/2171) Prevent the `next` link from getting populated in JSON:API when an out of bounds page is requested. (@bcaplan)
20+
- [#2200](https://github.com/rails-api/active_model_serializers/pull/2200) Fix deserialization of polymorphic relationships. (@dennis95stumm)
1721

1822
Misc:
1923

Gemfile

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ version = ENV['RAILS_VERSION'] || '4.2'
1212
if version == 'master'
1313
gem 'rack', github: 'rack/rack'
1414
gem 'arel', github: 'rails/arel'
15+
gem 'rails', github: 'rails/rails'
1516
git 'https://github.com/rails/rails.git' do
1617
gem 'railties'
1718
gem 'activesupport'
@@ -23,6 +24,7 @@ if version == 'master'
2324
end
2425
else
2526
gem_version = "~> #{version}.0"
27+
gem 'rails', gem_version
2628
gem 'railties', gem_version
2729
gem 'activesupport', gem_version
2830
gem 'activemodel', gem_version
@@ -36,18 +38,32 @@ end
3638
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
3739
gem 'tzinfo-data', platforms: (@windows_platforms + [:jruby])
3840

41+
if ENV['CI']
42+
if RUBY_VERSION < '2.4'
43+
# Windows: An error occurred while installing nokogiri (1.8.0)
44+
gem 'nokogiri', '< 1.7', platforms: @windows_platforms
45+
end
46+
end
47+
3948
group :bench do
4049
# https://github.com/rails-api/active_model_serializers/commit/cb4459580a6f4f37f629bf3185a5224c8624ca76
4150
gem 'benchmark-ips', '>= 2.7.2', require: false, group: :development
4251
end
4352

4453
group :test do
45-
gem 'sqlite3', platform: (@windows_platforms + [:ruby])
46-
gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
54+
gem 'sqlite3', platform: (@windows_platforms + [:ruby])
55+
platforms :jruby do
56+
if version == 'master' || version >= '5'
57+
gem 'activerecord-jdbcsqlite3-adapter', github: 'jruby/activerecord-jdbc-adapter', branch: 'rails-5'
58+
else
59+
gem 'activerecord-jdbcsqlite3-adapter'
60+
end
61+
end
4762
gem 'codeclimate-test-reporter', require: false
4863
gem 'm', '~> 1.5'
49-
gem 'pry', '~> 0.10'
50-
gem 'pry-byebug', '~> 3.4', platform: :ruby
64+
gem 'pry', '>= 0.10'
65+
gem 'byebug', '~> 8.2' if RUBY_VERSION < '2.2'
66+
gem 'pry-byebug', platform: :ruby
5167
end
5268

5369
group :development, :test do

active_model_serializers.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Gem::Specification.new do |spec|
4242
# 'minitest'
4343
# 'thread_safe'
4444

45-
spec.add_runtime_dependency 'jsonapi-renderer', ['>= 0.1.1.beta1', '< 0.2']
45+
spec.add_runtime_dependency 'jsonapi-renderer', ['>= 0.1.1.beta1', '< 0.3']
4646
spec.add_runtime_dependency 'case_transform', '>= 0.2'
4747

4848
spec.add_development_dependency 'activerecord', rails_versions

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ skip_tags: true
55
environment:
66
JRUBY_OPTS: "--dev -J-Xmx1024M --debug"
77
matrix:
8-
- ruby_version: "Ruby21"
9-
- ruby_version: "Ruby21-x64"
8+
- ruby_version: "Ruby23"
9+
- ruby_version: "Ruby23-x64"
1010

1111
cache:
1212
- vendor/bundle

lib/active_model/serializer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def attributes(requested_attrs = nil, reload = false)
337337
# @return [Enumerator<Association>]
338338
def associations(include_directive = ActiveModelSerializers.default_include_directive, include_slice = nil)
339339
include_slice ||= include_directive
340-
return Enumerator.new unless object
340+
return Enumerator.new {} unless object
341341

342342
Enumerator.new do |y|
343343
self.class._reflections.each do |key, reflection|

lib/active_model_serializers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ def self.silence_warnings
4949
require 'active_model/serializer/version'
5050
require 'active_model/serializer'
5151
require 'active_model/serializable_resource'
52-
require 'active_model_serializers/railtie' if defined?(::Rails)
52+
require 'active_model_serializers/railtie' if defined?(::Rails::Railtie)
5353
end

lib/active_model_serializers/adapter/json_api/deserialization.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def parse_relationship(assoc_name, assoc_data, options)
189189

190190
polymorphic = (options[:polymorphic] || []).include?(assoc_name.to_sym)
191191
if polymorphic
192-
hash["#{prefix_key}_type".to_sym] = assoc_data.present? ? assoc_data['type'] : nil
192+
hash["#{prefix_key}_type".to_sym] = assoc_data.present? ? assoc_data['type'].classify : nil
193193
end
194194

195195
hash

test/action_controller/json_api/deserialization_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_deserialization_of_relationship_only_object
4545
response = JSON.parse(@response.body)
4646
expected = {
4747
'restriction_for_id' => '67',
48-
'restriction_for_type' => 'discounts',
48+
'restriction_for_type' => 'Discount',
4949
'restricted_to_id' => nil,
5050
'restricted_to_type' => nil
5151
}

test/adapter/json_api/parse_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def test_polymorphic
125125
src: 'http://example.com/images/productivity.png',
126126
author_id: nil,
127127
photographer_id: '9',
128-
photographer_type: 'people',
128+
photographer_type: 'Person',
129129
comment_ids: %w(1 2)
130130
}
131131
assert_equal(expected, parsed_hash)

test/support/isolated_unit.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def make_basic_app
5454
require 'rails'
5555
require 'action_controller/railtie'
5656

57-
@app = Class.new(Rails::Application) do
57+
app = Class.new(Rails::Application) do
5858
config.eager_load = false
5959
config.session_store :cookie_store, key: '_myapp_session'
6060
config.active_support.deprecation = :log
@@ -67,8 +67,10 @@ def make_basic_app
6767
config.logger = fake_logger
6868
Rails.application.routes.default_url_options = { host: 'example.com' }
6969
end
70-
@app.respond_to?(:secrets) && @app.secrets.secret_key_base = '3b7cd727ee24e8444053437c36cc66c4'
70+
def app.name; 'IsolatedRailsApp'; end # rubocop:disable Style/SingleLineMethods
71+
app.respond_to?(:secrets) && app.secrets.secret_key_base = '3b7cd727ee24e8444053437c36cc66c4'
7172

73+
@app = app
7274
yield @app if block_given?
7375
@app.initialize!
7476
end

0 commit comments

Comments
 (0)