Commit Graph

10 Commits

Author SHA1 Message Date
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