-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: 7.1.0
-
Component/s: Persistence, Validations
-
Environment:Fedora 32 (x86-64)
Ruby: 2.7.1
Bundler: 2.1.4
MongoDB: MongoDB 4.2.8 Community
Mongodb Cluster: standalone
If we have two models, one is embedded to another.
We attached validation to parent and embedded ones.
If parent fields are valid, but embedded ones are invalid, `create!` method won't raise exception and create model into DB.
Steps to reproduce.
- boot to any Linux distributive
- install ruby, bundler, mongodb, start mongodb
- unpack attached archive, cd to it
- run `bundler install`
- run `bundler exec ruby ./all_is_well.rb`, see validation error as expected
- run `bundler exec ruby ./doesnt_throw_as_expected.rb`, see no validation error
- sorry, I can't setup it to work without Rails, so it shows another exception, but in Rais it just creates model. But if to check it later: `instance.valid?` - it returns false