Skip to content

Commit ad64f14

Browse files
authored
rails v6.1 compatibility (#1346)
1 parent 1dd5f18 commit ad64f14

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ env:
66
- "RAILS_VERSION=5.1.7"
77
- "RAILS_VERSION=5.2.3"
88
- "RAILS_VERSION=6.0.0"
9+
- "RAILS_VERSION=6.1.0"
910
rvm:
1011
- 2.3.8
1112
- 2.4.7
@@ -22,5 +23,9 @@ matrix:
2223
env: "RAILS_VERSION=6.0.0"
2324
- rvm: 2.4.7
2425
env: "RAILS_VERSION=6.0.0"
26+
- rvm: 2.3.8
27+
env: "RAILS_VERSION=6.1.0"
28+
- rvm: 2.4.7
29+
env: "RAILS_VERSION=6.1.0"
2530
before_install:
2631
- gem install bundler --version 1.17.3

lib/jsonapi/resource_controller_metal.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ class ResourceControllerMetal < ActionController::Metal
55
ActionController::Rendering,
66
ActionController::Renderers::All,
77
ActionController::StrongParameters,
8-
ActionController::ForceSSL,
8+
Gem::Requirement.new('< 6.1').satisfied_by?(ActionPack.gem_version) ? ActionController::ForceSSL : nil,
99
ActionController::Instrumentation,
1010
JSONAPI::ActsAsResourceController
11-
].freeze
11+
].compact.freeze
1212

1313
MODULES.each do |mod|
1414
include mod

test/fixtures/active_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ class Post < ActiveRecord::Base
370370
belongs_to :writer, class_name: 'Person', foreign_key: 'author_id'
371371
has_many :comments
372372
has_and_belongs_to_many :tags, join_table: :posts_tags
373-
has_many :special_post_tags, source: :tag
373+
has_many :special_post_tags
374374
has_many :special_tags, through: :special_post_tags, source: :tag
375375
belongs_to :section
376376
has_one :parent_post, class_name: 'Post', foreign_key: 'parent_post_id'

test/integration/requests/request_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ def test_caching_included_singleton
14301430
}
14311431

14321432
$test_user = Person.find(1)
1433-
assert_equal 2, JSONAPI.configuration.resource_cache.instance_variable_get(:@key_access).length
1433+
assert_equal 2, JSONAPI.configuration.resource_cache.instance_variable_get(:@data).length
14341434

14351435
get "/api/v9/people/#{$test_user.id}?include=preferences"
14361436
assert_jsonapi_response 200
@@ -1477,7 +1477,7 @@ def test_caching_included_singleton
14771477
]
14781478
}
14791479

1480-
assert_equal 4, JSONAPI.configuration.resource_cache.instance_variable_get(:@key_access).length
1480+
assert_equal 4, JSONAPI.configuration.resource_cache.instance_variable_get(:@data).length
14811481

14821482
ensure
14831483
JSONAPI.configuration = original_config
@@ -1522,7 +1522,7 @@ def test_caching_singleton_primary
15221522
}
15231523
}
15241524

1525-
assert_equal 1, JSONAPI.configuration.resource_cache.instance_variable_get(:@key_access).length
1525+
assert_equal 1, JSONAPI.configuration.resource_cache.instance_variable_get(:@data).length
15261526

15271527
$test_user = Person.find(1)
15281528

@@ -1550,7 +1550,7 @@ def test_caching_singleton_primary
15501550
}
15511551
}
15521552

1553-
assert_equal 2, JSONAPI.configuration.resource_cache.instance_variable_get(:@key_access).length
1553+
assert_equal 2, JSONAPI.configuration.resource_cache.instance_variable_get(:@data).length
15541554

15551555
ensure
15561556
JSONAPI.configuration = original_config

test/unit/resource/resource_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class PostWithBadAfterSave < ActiveRecord::Base
1313
after_save :do_some_after_save_stuff
1414

1515
def do_some_after_save_stuff
16-
errors[:base] << 'Boom! Error added in after_save callback.'
16+
errors.add(:base, 'Boom! Error added in after_save callback.')
1717
raise ActiveRecord::RecordInvalid.new(self)
1818
end
1919
end
@@ -23,7 +23,7 @@ class PostWithCustomValidationContext < ActiveRecord::Base
2323
validate :api_specific_check, on: :json_api_create
2424

2525
def api_specific_check
26-
errors[:base] << 'Record is invalid'
26+
errors.add(:base, 'Record is invalid')
2727
end
2828
end
2929

0 commit comments

Comments
 (0)