Allow frozen options in as_json (#4655)

The test uses `as_json` instead of `to_json` because `to_json` does `#dup` on `options` before it reaches `#serializable_hash` and the test would pass without the fix.
This commit is contained in:
Guilherme Goettems Schneider
2017-12-21 15:23:25 -02:00
committed by Leonardo Tegon
parent 1b02534bef
commit 8b9fba73fd
3 changed files with 6 additions and 1 deletions

View File

@@ -40,6 +40,10 @@ class SerializableTest < ActiveSupport::TestCase
assert_no_match(/confirmation_token/, @user.inspect)
end
test 'should accept frozen options' do
assert_key "username", @user.as_json({only: :username}.freeze)["user"]
end
def assert_key(key, subject)
assert subject.key?(key), "Expected #{subject.inspect} to have key #{key.inspect}"
end