aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/calculations_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-02-02 04:28:42 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2008-02-02 04:28:42 +0000
commit5bbc461fcbe18b0ab69c459a94cf0b58f5a4e6b9 (patch)
tree8fa372dcec9d6ae9822038cb590fbce4b92a6f4d /activerecord/test/cases/calculations_test.rb
parent6d8534acc032ab3a1ecbb88e9a0ce09d18734071 (diff)
downloadrails-5bbc461fcbe18b0ab69c459a94cf0b58f5a4e6b9.tar.gz
rails-5bbc461fcbe18b0ab69c459a94cf0b58f5a4e6b9.tar.bz2
rails-5bbc461fcbe18b0ab69c459a94cf0b58f5a4e6b9.zip
Fix calculations on associations with custom :foreign_key. Closes #8117 [kamal, jack]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8778 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r--activerecord/test/cases/calculations_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index 7e7beefb77..14987183eb 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -160,6 +160,14 @@ class CalculationsTest < ActiveRecord::TestCase
end
end
+ def test_should_calculate_grouped_association_with_foreign_key_option
+ Account.belongs_to :another_firm, :class_name => 'Firm', :foreign_key => 'firm_id'
+ c = Account.count(:all, :group => :another_firm)
+ assert_equal 1, c[companies(:first_firm)]
+ assert_equal 2, c[companies(:rails_core)]
+ assert_equal 1, c[companies(:first_client)]
+ end
+
def test_should_not_modify_options_when_using_includes
options = {:conditions => 'companies.id > 1', :include => :firm}
options_copy = options.dup