| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
Skipping `marked_for_destruction?` when the associated object does not responds
to it make easier to validate virtual associations built on top of Active Model
objects and/or serialized objects that implement a `valid?` instance method.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes #17621. This 5 year old (or older) issue causes validations to fire
when a parent record has `validate: false` option and a child record is
saved. It's not the responsibility of the model to validate an
associated object unless the object was created or modified by the
parent.
Clean up tests related to validations
`assert_nothing_raised` is not benefiting us in these tests
Corrected spelling of "respects"
It's better to use `assert_not_operator` over `assert !r.valid`
|
|
|
|
|
| |
Conflicts:
activerecord/test/cases/validations/association_validation_test.rb
|
| |
|
|
|
|
|
|
|
|
| |
This behaviour doesn't actually make sense, the context of
the child should not be affected by the parent. See #10492.
This reverts commit 5f8274efe128ffeec8fa3179460f5167a078f007, reversing
changes made to 81e837e810460d066a2e5fc5a795366ec8ab2313.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
E.G.:
```ruby
class Parent < ActiveRecord::Base
has_one :child
validates_presence_of :name, :on => "custom_context"
validates_associated :child
end
class Child < ActiveRecord::Base
belongs_to :parent
validates_presence_of :name, :on => "custom_context"
end
p = Parent.new(:name => "Montoto", :child => Child.new)
p.valid?(:custom_context) # => Returns true, even though the child is not valid under the same context.
```
|
|
|
|
| |
Testing Sandbox removed.
|
|
|
|
|
|
| |
The main reason for this change is to fix a bug where
`validates_associated` would prevent `accepts_nested_attributes_for`
with `allow_destroy: true` from destroying invalid associated records.
|
| |
|
|
|
|
| |
RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
fix the validation problem for a belongs_to relationship that validates_presence_of the parent, when both the parent and the child are new (in-memory) records. Also check that this works when the parents adds child via nested_attributes_for.
Lastly, add a require 'models/pet' to association_validation_test.rb, so that test can be run independently (was failing due to that missing dependency). [#2815 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
| |
|
|
|