diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-09-27 10:09:48 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-27 10:09:48 -0300 |
commit | f2f6a39ccae1508c69874c6952f7d12270b876af (patch) | |
tree | 49ba0491ed6b0d76e25c1340f419cb485bc6267b /activemodel/test/cases/errors_test.rb | |
parent | 7750b049eedfc639e3d5b8f06b51743d71962dd2 (diff) | |
parent | 33fd23e0772fab8932b66486e2c4993376db7f94 (diff) | |
download | rails-f2f6a39ccae1508c69874c6952f7d12270b876af.tar.gz rails-f2f6a39ccae1508c69874c6952f7d12270b876af.tar.bz2 rails-f2f6a39ccae1508c69874c6952f7d12270b876af.zip |
Merge pull request #26640 from Shopify/fix-am-errors-to-hash-default-proc
Do not leak the Errors default proc when calling to_hash or as_json
Diffstat (limited to 'activemodel/test/cases/errors_test.rb')
-rw-r--r-- | activemodel/test/cases/errors_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb index 3288b5543c..95ca1f3969 100644 --- a/activemodel/test/cases/errors_test.rb +++ b/activemodel/test/cases/errors_test.rb @@ -250,6 +250,16 @@ class ErrorsTest < ActiveModel::TestCase assert_equal({ name: ["cannot be blank"] }, person.errors.to_hash) end + test "to_hash returns a hash without default proc" do + person = Person.new + assert_nil person.errors.to_hash.default_proc + end + + test "as_json returns a hash without default proc" do + person = Person.new + assert_nil person.errors.as_json.default_proc + end + test "full_messages creates a list of error messages with the attribute name included" do person = Person.new person.errors.add(:name, "cannot be blank") |