mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Follows inheritance with a namespace
Co-authored-by: Rafael Gaspar <rafael.gaspar@me.com> Co-authored-by: Darryl Pogue <darryl@dpogue.ca> Co-authored-by: Artin Boghosian <artinboghosian@gmail.com>
This commit is contained in:
parent
777fab04ae
commit
beffbb2bd3
@ -17,6 +17,7 @@ Fixes:
|
|||||||
- [#2223](https://github.com/rails-api/active_model_serializers/pull/2223) Support Fieldset in Attributes/JSON adapters documented in [docs/general/fields.md](https://github.com/rails-api/active_model_serializers/blob/0-10-stable/docs/general/fields.md) that worked partially before (@bf4)
|
- [#2223](https://github.com/rails-api/active_model_serializers/pull/2223) Support Fieldset in Attributes/JSON adapters documented in [docs/general/fields.md](https://github.com/rails-api/active_model_serializers/blob/0-10-stable/docs/general/fields.md) that worked partially before (@bf4)
|
||||||
- [#2337](https://github.com/rails-api/active_model_serializers/pull/2337) fix incorrect belongs_to serialization when foreign_key on object and belongs_to is blank (@InteNs)
|
- [#2337](https://github.com/rails-api/active_model_serializers/pull/2337) fix incorrect belongs_to serialization when foreign_key on object and belongs_to is blank (@InteNs)
|
||||||
- Fixes incorrect json-api generation when `jsonapi_use_foreign_key_on_belongs_to_relationship` is `true` and the relationship is blank
|
- Fixes incorrect json-api generation when `jsonapi_use_foreign_key_on_belongs_to_relationship` is `true` and the relationship is blank
|
||||||
|
- [#2172](https://github.com/rails-api/active_model_serializers/pull/2172) Preserve the namespace when falling back to a superclass serializer
|
||||||
|
|
||||||
Misc:
|
Misc:
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,7 @@ module ActiveModel
|
|||||||
if serializer_class
|
if serializer_class
|
||||||
serializer_class
|
serializer_class
|
||||||
elsif klass.superclass
|
elsif klass.superclass
|
||||||
get_serializer_for(klass.superclass)
|
get_serializer_for(klass.superclass, namespace)
|
||||||
else
|
else
|
||||||
nil # No serializer found
|
nil # No serializer found
|
||||||
end
|
end
|
||||||
|
|||||||
@ -9,6 +9,7 @@ module ActiveModel
|
|||||||
attributes :title, :author_name
|
attributes :title, :author_name
|
||||||
associations :publisher, :pages
|
associations :publisher, :pages
|
||||||
end
|
end
|
||||||
|
class Ebook < Book; end
|
||||||
class Page < ::Model; attributes :number, :text end
|
class Page < ::Model; attributes :number, :text end
|
||||||
class Publisher < ::Model; attributes :name end
|
class Publisher < ::Model; attributes :name end
|
||||||
|
|
||||||
@ -85,6 +86,11 @@ module ActiveModel
|
|||||||
}
|
}
|
||||||
assert_equal expected, result
|
assert_equal expected, result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'follows inheritance with a namespace' do
|
||||||
|
serializer = ActiveModel::Serializer.serializer_for(Ebook.new, namespace: Api::V3)
|
||||||
|
assert_equal Api::V3::BookSerializer, serializer
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user