[#365] Support frozen array in option
This commit is contained in:
parent
021db27605
commit
1a407c0030
@ -86,7 +86,7 @@ module FastJsonapi
|
||||
raise ArgumentError.new("`params` option passed to serializer must be a hash") unless @params.is_a?(Hash)
|
||||
|
||||
if options[:include].present?
|
||||
@includes = options[:include].delete_if(&:blank?).map(&:to_sym)
|
||||
@includes = options[:include].reject(&:blank?).map(&:to_sym)
|
||||
self.class.validate_includes!(@includes)
|
||||
end
|
||||
end
|
||||
|
@ -473,6 +473,16 @@ describe FastJsonapi::ObjectSerializer do
|
||||
options[:include] = [:actors]
|
||||
expect(serializable_hash['included']).to be_blank
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
context 'when include has frozen array' do
|
||||
let(:options) { { include: [:actors].freeze }}
|
||||
let(:json) { MovieOptionalRelationshipSerializer.new(movie, options).serialized_json }
|
||||
|
||||
it 'does not raise and error' do
|
||||
expect(json['included']).to_not be_blank
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user