aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/join_model_test.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-12-15 23:27:15 +0000
committerAaron Patterson <aaron.patterson@gmail.com>2010-12-15 17:50:14 -0800
commit14b880fd035fcdf807051398674c9aa89bd3b4d3 (patch)
tree6f80999405dea289391abfdf4552cea407d9cd45 /activerecord/test/cases/associations/join_model_test.rb
parent09ddca67acbb88e2fdd7300670839cbf647b2694 (diff)
downloadrails-14b880fd035fcdf807051398674c9aa89bd3b4d3.tar.gz
rails-14b880fd035fcdf807051398674c9aa89bd3b4d3.tar.bz2
rails-14b880fd035fcdf807051398674c9aa89bd3b4d3.zip
Fix various issues with the :primary_key option in :through associations [#2421 state:resolved]
Diffstat (limited to 'activerecord/test/cases/associations/join_model_test.rb')
-rw-r--r--activerecord/test/cases/associations/join_model_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/join_model_test.rb b/activerecord/test/cases/associations/join_model_test.rb
index 4581cb1acd..0a57c7883f 100644
--- a/activerecord/test/cases/associations/join_model_test.rb
+++ b/activerecord/test/cases/associations/join_model_test.rb
@@ -298,6 +298,22 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase
assert_equal [authors(:mary)], posts(:authorless).authors
end
+ def test_has_many_going_through_join_model_with_custom_primary_key
+ assert_equal [authors(:david)], posts(:thinking).authors_using_author_id
+ end
+
+ def test_has_many_going_through_polymorphic_join_model_with_custom_primary_key
+ assert_equal [tags(:general)], posts(:eager_other).tags_using_author_id
+ end
+
+ def test_has_many_through_with_custom_primary_key_on_belongs_to_source
+ assert_equal [authors(:david), authors(:david)], posts(:thinking).author_using_custom_pk
+ end
+
+ def test_has_many_through_with_custom_primary_key_on_has_many_source
+ assert_equal [authors(:david)], posts(:thinking).authors_using_custom_pk
+ end
+
def test_both_scoped_and_explicit_joins_should_be_respected
assert_nothing_raised do
Post.send(:with_scope, :find => {:joins => "left outer join comments on comments.id = posts.id"}) do