Skip to content

Commit

Permalink
[#365] Support frozen array in option
Browse files Browse the repository at this point in the history
  • Loading branch information
dapi authored and kpheasey committed Oct 4, 2019
1 parent 021db27 commit 1a407c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fast_jsonapi/object_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def process_options(options)
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
Expand Down
10 changes: 10 additions & 0 deletions spec/lib/object_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,16 @@ class BlahSerializer
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

Expand Down

0 comments on commit 1a407c0

Please sign in to comment.