aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb4
-rw-r--r--activerecord/test/fixtures/companies.yml1
-rwxr-xr-xactiverecord/test/models/company.rb2
-rw-r--r--activerecord/test/schema/schema.rb1
4 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 247726bc61..e90edbb213 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -129,6 +129,10 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal "Microsoft", Firm.find(:first).clients_like_ms_with_hash_conditions.first.name
end
+ def test_finding_using_primary_key
+ assert_equal "Summit", Firm.find(:first).clients_using_primary_key.first.name
+ end
+
def test_finding_using_sql
firm = Firm.find(:first)
first_client = firm.clients_using_sql.first
diff --git a/activerecord/test/fixtures/companies.yml b/activerecord/test/fixtures/companies.yml
index c61128c09b..e7691fde46 100644
--- a/activerecord/test/fixtures/companies.yml
+++ b/activerecord/test/fixtures/companies.yml
@@ -5,6 +5,7 @@ first_client:
client_of: 2
name: Summit
ruby_type: Client
+ firm_name: 37signals
first_firm:
id: 1
diff --git a/activerecord/test/models/company.rb b/activerecord/test/models/company.rb
index 9fa810ac68..c45a21b6a2 100755
--- a/activerecord/test/models/company.rb
+++ b/activerecord/test/models/company.rb
@@ -46,6 +46,8 @@ class Firm < Company
has_many :clients_using_finder_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE 1=1'
has_many :plain_clients, :class_name => 'Client'
has_many :readonly_clients, :class_name => 'Client', :readonly => true
+ has_many :clients_using_primary_key, :class_name => 'Client',
+ :primary_key => 'name', :foreign_key => 'firm_name'
has_one :account, :foreign_key => "firm_id", :dependent => :destroy, :validate => true
has_one :unvalidated_account, :foreign_key => "firm_id", :class_name => 'Account', :validate => false
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index 234c43494a..29c91a4464 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -102,6 +102,7 @@ ActiveRecord::Schema.define do
t.string :type
t.string :ruby_type
t.integer :firm_id
+ t.string :firm_name
t.string :name
t.integer :client_of
t.integer :rating, :default => 1