diff options
author | Esteban Pastorino <ejpastorino@gmail.com> | 2016-03-24 10:27:31 -0400 |
---|---|---|
committer | Esteban Pastorino <ejpastorino@gmail.com> | 2016-03-24 16:29:22 -0400 |
commit | 9848c4632f0a9be19bf8cb9b8aaa146e28602e30 (patch) | |
tree | 55b2e8398aede2eb4e801bc127eb821bf02d5723 /actioncable/test/test_helper.rb | |
parent | 00a0388adcb2a09cb811ee9659636a154c36bca5 (diff) | |
download | rails-9848c4632f0a9be19bf8cb9b8aaa146e28602e30.tar.gz rails-9848c4632f0a9be19bf8cb9b8aaa146e28602e30.tar.bz2 rails-9848c4632f0a9be19bf8cb9b8aaa146e28602e30.zip |
Do not create a hash key when calling ActiveModel::Errors#include?
From: https://github.com/rails/rails/issues/24279
Problem:
By doing `record.errors.include? :foo`, it adds a new key to the
@messages hash that defaults to an empty array.
This happens because of a combination of these 2 commits:
https://github.com/rails/rails/commit/b97035df64f5b2f912425c4a7fcb6e6bb3ddab8d
(Added in Rails 4.1)
and
https://github.com/rails/rails/commit/6ec8ba16d85d5feaccb993c9756c1edcbbf0ba13#diff-fdcf8b65b5fb954372c6fe1ddf284c78R76
(Rails 5.0)
By adding the default proc that returns an array for non-existing keys,
ruby adds that key to the hash.
Solution:
Change `#include?` to check with `has_key?` and then check if that value is
`present?`.
Add test case for ActiveModels::Errors#include?
Diffstat (limited to 'actioncable/test/test_helper.rb')
0 files changed, 0 insertions, 0 deletions