1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

15 commits

Author SHA1 Message Date
Takehiro Adachi
0123c39f41 Add test to AR's counter_cache_test.rb
According to
https://github.com/rails/rails/blob/b601399b72ab56cc01368f02615af99f45d1
4f02/activerecord/lib/active_record/counter_cache.rb#L14, u can pass
more then one association to the `reset_counters` method.
2013-05-18 17:12:46 +09:00
Aaron Patterson
db3a6e6a7f squelch an unused variable warning 2013-03-22 19:41:13 -07:00
Ian Young
66679c8ecd Update other counter caches on destroy 2013-03-20 13:43:07 -07:00
Mack Earnhardt
1d6eabb677 Refactor Person/Friendship relationships to be more intuitive
PR #5210 added a Friendship model to illustrate a bug, but in doing so
created a confusing structure because both belongs_to declarations in
Friendship referred to the same side of the join. The new structure
maintains the integrity of the bug test while changing the follower
relationship to be more useful for other testing.
2013-03-17 02:11:19 -04:00
Yves Senn
b601399b72 #reset_counters verifies counter names.
Closes #9724.

Raise an `ArgumentError` when the name of the counter does not
match an association name.
2013-03-15 11:22:01 +01:00
lulalala
6e56a03f83 Fix reset_counters() crashing on has_many :through associations.
The counter column name in the intermediate model need to be access
via the through reflection.
2012-10-02 23:49:32 +08:00
Dave Desrochers
ff0d9b93b9 reset_counters() was crashing when there were multiple belongs_to associations with the same foreign key.
This closes #5200.
2012-08-21 14:10:11 -03:00
David Peter
ee013a503d Fix bug where reset_counters resets the wrong counter cache.
If a model belongs_to two associations with the same class, then reset_counters
will reset the wrong counter cache.

Finding the right reflection should use the foreign_key instead, which should
be unique.
2012-01-16 19:06:45 -08:00
Aaron Patterson
61774e0d49 please use ruby -I lib:test path/to/test.rb, or export RUBY_OPT 2011-06-06 15:47:13 -07:00
Jon Leighton
253bb6b926 Refactor Active Record test connection setup. Please see the 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. 2011-06-04 23:47:03 +01:00
Santiago Pastorino
b451de0d6d Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;) 2010-08-14 04:12:33 -03:00
Neeraj Singh
1e53404fe9 reset_counter should work with non-traditional belongs_to and polymorphic belongs_to
[#4984 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 23:24:12 +02:00
rohit
95a8f252c0 remove executable permission from files that don't need it. [#4802 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-20 00:50:48 +02:00
Mislav Marohnić
bc84bd17d1 fix reset_counters to work even with complex class names
e.g. it guesses that a belongs_to association to Namespace::MyModel is
named "my_model", unlike before where it would look up an association
named "namespace::mymodel" and fail.
2010-05-24 11:44:53 +02:00
Mislav Marohnić
bfca7d744d move counter_cache tests to a separate file and refactor 2010-05-24 11:42:03 +02:00