diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-01-21 23:40:20 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-01-21 23:40:20 +0000 |
commit | 1facce6c244713bb88e4ed70222f0d42b30736de (patch) | |
tree | 142f45fc3e4a9f9111d8206ea9276520fdc1ee83 /activerecord/test | |
parent | 13cd6135cdb50d897441dfa4d1572311632ab924 (diff) | |
download | rails-1facce6c244713bb88e4ed70222f0d42b30736de.tar.gz rails-1facce6c244713bb88e4ed70222f0d42b30736de.tar.bz2 rails-1facce6c244713bb88e4ed70222f0d42b30736de.zip |
allow has_many :through to work with custom :foreign key (closes #3422) [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3456 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/associations_join_model_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/fixtures/post.rb | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb index a011a0fae8..61488900d6 100644 --- a/activerecord/test/associations_join_model_test.rb +++ b/activerecord/test/associations_join_model_test.rb @@ -68,5 +68,9 @@ class AssociationsJoinModelTest < Test::Unit::TestCase assert_equal categories(:general), authors(:david).categories.find_by_name('General') # assert_equal nil, authors(:david).categories.find_by_name('Technology') end - + + def test_has_many_going_through_join_model_with_custom_foreign_key + assert_equal [], posts(:thinking).authors + assert_equal [authors(:mary)], posts(:authorless).authors + end end diff --git a/activerecord/test/fixtures/post.rb b/activerecord/test/fixtures/post.rb index 97b25179f5..ada18af115 100644 --- a/activerecord/test/fixtures/post.rb +++ b/activerecord/test/fixtures/post.rb @@ -23,6 +23,9 @@ class Post < ActiveRecord::Base has_many :taggings, :as => :taggable has_many :tags, :through => :taggings + has_many :categorizations, :foreign_key => :category_id + has_many :authors, :through => :categorizations + def self.what_are_you 'a post...' end |