| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
assert_raise + assert_equal on the returned exception message work
just fine, there is no need for extra work, specially like this overly
complicated helper.
|
|
|
|
|
|
|
|
| |
Follow-Up to https://github.com/rails/rails/pull/14348
Ensure that SQLCounter.clear_log is called after each test.
This is a step to prevent side effects when running tests. This will allow us to run them in random order.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
recreate the models without mucking with internal caches of the relation
objects, then the test fails.
For example:
class Man < ActiveRecord::Base
has_many :interests
end
class Interest < ActiveRecord::Base
belongs_to :man
end
Then do this test:
def test_validate_presence_of_parent_fails_without_inverse_of
repair_validations(Interest) do
Interest.validates_presence_of(:man)
assert_no_difference ['Man.count', 'Interest.count'] do
man = Man.create(:name => 'John',
:interests_attributes => [{:topic=>'Cars'}, {:topic=>'Sports'}])
assert_not_predicate man.errors[:"interests.man"], :empty?
end
end
end
The test will fail. This is a bad test, so I am removing it.
|
| |
|
|
|
|
|
|
| |
the results. Added tests to check to make sure that inverse associations are
automatically found when has_many, has_one, or belongs_to associations
are defined.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
assignment
For one-to-one nested associations, if you build the new (in-memory)
child object yourself before assignment, then the NestedAttributes
module will not overwrite it, e.g.:
class Member < ActiveRecord::Base
has_one :avatar
accepts_nested_attributes_for :avatar
def avatar
super || build_avatar(width: 200)
end
end
member = Member.new
member.avatar_attributes = {icon: 'sad'}
member.avatar.width # => 200
|
|
|
|
|
| |
Introduce test on Error#full_message for attribute with underscores; Fix
some typos
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
Also refactor the test a bit.
|
| |
|
|\
| |
| |
| |
| | |
jcoleman/should-unset-association-when-an-existing-record-is-destroyed
Unset association when existing record is destroyed.
|
| |
| |
| |
| | |
To avoid foreign key errors (and invalid data) in the database, when a belongs_to association is destroyed, it should also be nil'd out on the parent object.
|
| | |
|
| |
| |
| |
| | |
#accepts_nested_attributes_for
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This happens when A has_many many B and A accepts_nested_attributes B that has a numeric colum
with initial 0 value. So a.update_attributes({:b_attributes => { :id => b.id, :numeric => 'foo' }})
passes the validation test but, the value of :numeric doesn't change.
his commit forces that the update fails with the above conditions.
Fixes #6393
Fixes #2331
|
| |
| |
| |
| | |
Overriding implementation can call super.
|
| | |
|
|/ |
|
|
|
|
| |
strict mass assignment sanitizer, fixed build_record to not merge creation_attributes, removed failing nested attributes tests (that feature was broken anyway) #4051
|
|
|
|
| |
object. Fixes a regression from 3.0.x
|
| |
|
|
|
|
|
|
| |
1.9 [Closes #2106]
Children attributes can be either String's or Symbol's, so let's check if the object responds to to_i.
|
| |
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
- When a :_destroy truthiness is provided in the attributes hash, the
record should get destroyed regardless of the result of the proc or
method supplied to :reject_if. (If :allow_destroy is true)
[#6006 state:committed]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
|
|
|
| |
manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more.
|
| |
|
|
|
|
| |
tributes_are_set_to_update_existing_record added
|
|
|
|
| |
fixtures when the DB does not support savepoints. This speeds the test run up by about 8-9% on my computer, when running rake test_sqlite3_mem :)
|
|
|
|
|
|
|
|
|
|
| |
state:resolved]
This required changing the code to keep the association proxy for a belongs_to around, despite its target being nil. Which in turn required various changes to the way that stale target checking is handled, in order to support various edge cases (loaded target is nil then foreign key added, foreign key is changed and then changed back, etc). A side effect is that the code is nicer and more succinct.
Note that I am removing test_no_unexpected_aliasing since that is basically checking that the proxy for a belongs_to *does* change, which is the exact opposite of the intention of this commit. Also adding various tests for various edge cases and related things.
Phew, long commit message!
|
|
|
|
| |
changes. Rather than resetting each affected association when the foreign key changes, we should lazily check for 'staleness' (where fk does not match target id) when the association is accessed.
|
| |
|
|
|
|
|
|
|
|
| |
an attr_accessor value is being assigned then the value being assigned is being ignored. This patch is a fix for that issue.
[#5939 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
|
|
| |
an ActiveRecord::RecordNotFound error. Found by [Ben Tillman]
[#5638 state:committed]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
|
|
|
|
|
|
|
|
|
|
| |
- persisted? is the API defined in ActiveModel
- makes it easier for extension libraries to conform to ActiveModel APIs
without concern for whether the extended object is specifically
ActiveRecord
[#5927 state:committed]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
|
|
|
|
|
|
|
|
|
| |
vulnerability.
This addresses CVE-2010-3933
Conflicts:
activerecord/lib/active_record/nested_attributes.rb
|
| |
|
|
|
|
|
|
|
|
| |
relationships. The path included test only for has_one. This patch adds test for has_many relationship.
[#5706 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
|
|
| |
record is being updated.
[#5705 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
| |
[#5579 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
| |
not on assert_difference [#5206 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
| |
's/[ \t]*$//' -i {} \;)
|
|
|
|
| |
Signed-off-by: wycats <wycats@gmail.com>
|
|
|
|
|
|
|
|
| |
from db if it is already loaded by nested attributes assignment
[#5053 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
|
|
| |
record is saved and then in memory record attributes should be saved
[#5053 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|