Ensure serializable_hash doesn't raise with a frozen :except array

I ran into an issue where options[:except] is a frozen array, which
explodes when we try to concat values in `serializable_hash`. To fix this
we dup the `:except` option before concatenating with the other options
there.

Closes #5278.
This commit is contained in:
Daniel Pepper
2020-08-12 13:19:50 -07:00
committed by Carlos Antonio da Silva
parent f26e05c200
commit 507573994a
3 changed files with 7 additions and 2 deletions

View File

@@ -43,7 +43,7 @@ class SerializableTest < ActiveSupport::TestCase
end
test 'should accept frozen options' do
assert_key "username", @user.as_json({only: :username}.freeze)["user"]
assert_key "username", @user.as_json({ only: :username, except: [:email].freeze }.freeze)["user"]
end
def assert_key(key, subject)