aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-03-19 19:32:07 +0000
committerRick Olson <technoweenie@gmail.com>2006-03-19 19:32:07 +0000
commit9a72cd22cf427754a30af409c4651da2017296a8 (patch)
tree1f616bb17910fdc6a0c530e1bac2ee48db3f6b65 /activerecord/test
parent48e7edc31b873c343d3e696fc02af354a74f0683 (diff)
downloadrails-9a72cd22cf427754a30af409c4651da2017296a8.tar.gz
rails-9a72cd22cf427754a30af409c4651da2017296a8.tar.bz2
rails-9a72cd22cf427754a30af409c4651da2017296a8.zip
Don't classify the has_one class when eager loading, it is already singular. Add tests. (closes #4117) [jonathan@bluewire.net.nz]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3983 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/associations_join_model_test.rb7
-rw-r--r--activerecord/test/fixtures/author.rb6
-rw-r--r--activerecord/test/fixtures/db_definitions/schema.rb5
3 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb
index d7a230ddba..ee99d77931 100644
--- a/activerecord/test/associations_join_model_test.rb
+++ b/activerecord/test/associations_join_model_test.rb
@@ -287,6 +287,13 @@ class AssociationsJoinModelTest < Test::Unit::TestCase
end
end
+ def test_eager_belongs_to_and_has_one_not_singularized
+ assert_nothing_raised do
+ Author.find(:first, :include => :author_address)
+ AuthorAddress.find(:first, :include => :author)
+ end
+ end
+
private
# create dynamic Post models to allow different dependency options
def find_post_with_dependency(post_id, association, association_name, dependency)
diff --git a/activerecord/test/fixtures/author.rb b/activerecord/test/fixtures/author.rb
index 1dda0f837c..e510dd1992 100644
--- a/activerecord/test/fixtures/author.rb
+++ b/activerecord/test/fixtures/author.rb
@@ -28,6 +28,8 @@ class Author < ActiveRecord::Base
has_many :nothings, :through => :kateggorisatons, :class_name => 'Category'
+ belongs_to :author_address
+
attr_accessor :post_log
def after_initialize
@@ -55,3 +57,7 @@ class Author < ActiveRecord::Base
raise Exception.new("You can't add a post")
end
end
+
+class AuthorAddress < ActiveRecord::Base
+ has_one :author
+end \ No newline at end of file
diff --git a/activerecord/test/fixtures/db_definitions/schema.rb b/activerecord/test/fixtures/db_definitions/schema.rb
index efe9cb35ab..6e8e23a9c4 100644
--- a/activerecord/test/fixtures/db_definitions/schema.rb
+++ b/activerecord/test/fixtures/db_definitions/schema.rb
@@ -19,5 +19,10 @@ ActiveRecord::Schema.define do
end
add_column :posts, :taggings_count, :integer, :default => 0
+ add_column :authors, :author_address_id, :integer
+
+ create_table :author_addresses, :force => true do |t|
+ t.column :author_address_id, :integer
+ end
end \ No newline at end of file