Skip to content

Commit 6fb4f7b

Browse files
authored
Merge pull request #2319 from kylekeesling/rails6
Fix deprecation warnings on Rails 6
2 parents bb0f9d0 + 912af7e commit 6fb4f7b

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Breaking changes:
77
Features:
88

99
Fixes:
10+
- [#2319](https://github.com/rails-api/active_model_serializers/pull/2319) Fixes #2316. (@kylekeesling)
11+
- Fix Rails 6.0 deprication warnings
12+
- update test fixture schema to use `timestamps` instead of `timestamp`
1013

1114
Misc:
1215

lib/action_controller/serialization.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ def serialization_scope(scope)
2323
end
2424

2525
def namespace_for_serializer
26-
@namespace_for_serializer ||= self.class.parent unless self.class.parent == Object
26+
@namespace_for_serializer ||= namespace_for_class(self.class) unless namespace_for_class(self.class) == Object
27+
end
28+
29+
def namespace_for_class(klass)
30+
if Module.method_defined?(:module_parent)
31+
klass.module_parent
32+
else
33+
klass.parent
34+
end
2735
end
2836

2937
def serialization_scope

test/action_controller/namespace_lookup_test.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,12 @@ def namespace_set_by_request_headers
125125
tests Api::V3::LookupTestController
126126

127127
setup do
128-
@test_namespace = self.class.parent
128+
@test_namespace =
129+
if Module.method_defined?(:module_parent)
130+
self.class.module_parent
131+
else
132+
self.class.parent
133+
end
129134
end
130135

131136
test 'uses request headers to determine the namespace' do

test/fixtures/active_record.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,28 @@
1919
t.text :contents
2020
t.references :author
2121
t.references :post
22-
t.timestamp null: false
22+
t.timestamps null: false
2323
end
2424
create_table :employees, force: true do |t|
2525
t.string :name
2626
t.string :email
27-
t.timestamp null: false
27+
t.timestamps null: false
2828
end
2929
create_table :object_tags, force: true do |t|
3030
t.string :poly_tag_id
3131
t.string :taggable_type
3232
t.string :taggable_id
33-
t.timestamp null: false
33+
t.timestamps null: false
3434
end
3535
create_table :poly_tags, force: true do |t|
3636
t.string :phrase
37-
t.timestamp null: false
37+
t.timestamps null: false
3838
end
3939
create_table :pictures, force: true do |t|
4040
t.string :title
4141
t.string :imageable_type
4242
t.string :imageable_id
43-
t.timestamp null: false
43+
t.timestamps null: false
4444
end
4545
end
4646

0 commit comments

Comments
 (0)