[#365] Support frozen array in option

This commit is contained in:
Danil Pismenny 2018-12-21 18:41:55 +03:00 committed by Kevin Pheasey
parent 021db27605
commit 1a407c0030
2 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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