Skip to content

Commit 8d8eaec

Browse files
dapiThomas
authored and
Thomas
committed
[Netflix#365] Support frozen array in option
1 parent 5867bf8 commit 8d8eaec

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/fast_jsonapi/object_serializer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def process_options(options)
8585
raise ArgumentError.new("`params` option passed to serializer must be a hash") unless @params.is_a?(Hash)
8686

8787
if options[:include].present?
88-
@includes = options[:include].delete_if(&:blank?).map(&:to_sym)
88+
@includes = options[:include].reject(&:blank?).map(&:to_sym)
8989
self.class.validate_includes!(@includes)
9090
end
9191
end

spec/lib/object_serializer_spec.rb

+10
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,16 @@ class BlahSerializer
473473
options[:include] = [:actors]
474474
expect(serializable_hash['included']).to be_blank
475475
end
476+
477+
end
478+
end
479+
480+
context 'when include has frozen array' do
481+
let(:options) { { include: [:actors].freeze }}
482+
let(:json) { MovieOptionalRelationshipSerializer.new(movie, options).serialized_json }
483+
484+
it 'does not raise and error' do
485+
expect(json['included']).to_not be_blank
476486
end
477487
end
478488

0 commit comments

Comments
 (0)