aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorAndrew White <pixeltrix@users.noreply.github.com>2015-10-22 09:54:04 +0100
committerAndrew White <pixeltrix@users.noreply.github.com>2015-10-22 09:54:04 +0100
commitf66b68173a11d0ef8f4bb6253386c15d031017ba (patch)
treec4e46cd8ae0b38303133f15965d46efb4c64110a /activerecord/test
parent94db9b6f1dc0f03b36fda37b7ee914c594105e66 (diff)
parent4f21d42faaf12955fa0116306966d4ef09e62462 (diff)
downloadrails-f66b68173a11d0ef8f4bb6253386c15d031017ba.tar.gz
rails-f66b68173a11d0ef8f4bb6253386c15d031017ba.tar.bz2
rails-f66b68173a11d0ef8f4bb6253386c15d031017ba.zip
Merge pull request #21950 from rafaelsales/issues/21922-fix-ar-group-by-attribute-lookup
Fix generated projection fields in group by query
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/calculations_test.rb5
-rw-r--r--activerecord/test/models/company.rb1
2 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index a0e4b4971b..4a0e6f497f 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -455,6 +455,11 @@ class CalculationsTest < ActiveRecord::TestCase
[1,6,2,9].each { |firm_id| assert c.keys.include?(firm_id) }
end
+ def test_should_count_field_of_root_table_with_conflicting_group_by_column
+ assert_equal({ 1 => 1 }, Firm.joins(:accounts).group(:firm_id).count)
+ assert_equal({ 1 => 1 }, Firm.joins(:accounts).group('accounts.firm_id').count)
+ end
+
def test_count_with_no_parameters_isnt_deprecated
assert_not_deprecated { Account.count }
end
diff --git a/activerecord/test/models/company.rb b/activerecord/test/models/company.rb
index a96b8ef0f2..1dcd9fc21e 100644
--- a/activerecord/test/models/company.rb
+++ b/activerecord/test/models/company.rb
@@ -10,7 +10,6 @@ class Company < AbstractCompany
has_one :dummy_account, :foreign_key => "firm_id", :class_name => "Account"
has_many :contracts
has_many :developers, :through => :contracts
- has_many :accounts
scope :of_first_firm, lambda {
joins(:account => :firm).