diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-04-02 09:38:36 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-04-02 09:38:36 -0700 |
commit | 22fee7cbe368c64afa5292bd04ccbe96325c2a83 (patch) | |
tree | 429e8f3b4eed077fded24c6897b934b913a74965 /activerecord/test/cases/coders | |
parent | f95111e1d2f14860b445e01a4fd32e3184c07d4b (diff) | |
parent | 1bf6b53aa4de9267dcca42382d841cf96e98b55f (diff) | |
download | rails-22fee7cbe368c64afa5292bd04ccbe96325c2a83.tar.gz rails-22fee7cbe368c64afa5292bd04ccbe96325c2a83.tar.bz2 rails-22fee7cbe368c64afa5292bd04ccbe96325c2a83.zip |
Merge pull request #9975 from mmangino/raise_when_attributes_cant_be_unserialized
Unserializing YAML attributes can silently fail in development mode
Diffstat (limited to 'activerecord/test/cases/coders')
-rw-r--r-- | activerecord/test/cases/coders/yaml_column_test.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/activerecord/test/cases/coders/yaml_column_test.rb b/activerecord/test/cases/coders/yaml_column_test.rb index b874adc081..b72c54f97b 100644 --- a/activerecord/test/cases/coders/yaml_column_test.rb +++ b/activerecord/test/cases/coders/yaml_column_test.rb @@ -43,10 +43,20 @@ module ActiveRecord assert_equal [], coder.load([]) end - def test_load_swallows_yaml_exceptions + def test_load_doesnt_swallow_yaml_exceptions coder = YAMLColumn.new bad_yaml = '--- {' - assert_equal bad_yaml, coder.load(bad_yaml) + assert_raises(Psych::SyntaxError) do + coder.load(bad_yaml) + end + end + + def test_load_doesnt_handle_undefined_class_or_module + coder = YAMLColumn.new + missing_class_yaml = '--- !ruby/object:DoesNotExistAndShouldntEver {}\n' + assert_raises(ArgumentError) do + coder.load(missing_class_yaml) + end end end end |