mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 14:29:31 +00:00
Merge pull request #1006 from bf4/inflector-testing
Fix adapter inflection bug for api -> API
This commit is contained in:
commit
6266b6a002
@ -33,7 +33,8 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def self.adapter_class(adapter)
|
||||
"ActiveModel::Serializer::Adapter::#{adapter.to_s.classify}".safe_constantize
|
||||
adapter_name = adapter.to_s.classify.sub("API", "Api")
|
||||
"ActiveModel::Serializer::Adapter::#{adapter_name}".safe_constantize
|
||||
end
|
||||
|
||||
def fragment_cache(*args)
|
||||
@ -42,7 +43,7 @@ module ActiveModel
|
||||
|
||||
private
|
||||
|
||||
def cache_check(serializer)
|
||||
def cache_check(serializer)
|
||||
@cached_serializer = serializer
|
||||
@klass = @cached_serializer.class
|
||||
if is_cached?
|
||||
|
||||
@ -38,6 +38,15 @@ module ActiveModel
|
||||
adapter = ActiveModel::Serializer::Adapter.create(@serializer, { adapter: :json_api})
|
||||
assert_equal ActiveModel::Serializer::Adapter::JsonApi, adapter.class
|
||||
end
|
||||
|
||||
def test_inflected_adapter_class_for_known_adapter
|
||||
ActiveSupport::Inflector.inflections(:en){|inflect| inflect.acronym 'API' }
|
||||
klass = ActiveModel::Serializer::Adapter.adapter_class(:json_api)
|
||||
|
||||
ActiveSupport::Inflector.inflections.acronyms.clear
|
||||
|
||||
assert_equal ActiveModel::Serializer::Adapter::JsonApi, klass
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user