diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-02-14 20:39:51 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-02-18 00:00:13 +0000 |
commit | f0b98050296b57d95dbc789f8e52fa82499d151a (patch) | |
tree | 817c7fa99ab5119b6db4a95f5fe2f415975cae54 /activerecord/test/cases/associations | |
parent | b131cfba055bfbf25f3785c5235c1edbf04ff9f1 (diff) | |
download | rails-f0b98050296b57d95dbc789f8e52fa82499d151a.tar.gz rails-f0b98050296b57d95dbc789f8e52fa82499d151a.tar.bz2 rails-f0b98050296b57d95dbc789f8e52fa82499d151a.zip |
Ensure that association_ids uses the correct attribute where the association is a has_many :through with a :primary_key option on the source reflection. [#6376 state:resolved]
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index 73b1d6c500..7e77539fe7 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -718,4 +718,14 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase assert_equal post.tags, post.interpolated_tags assert_equal post.tags, post.interpolated_tags_2 end + + def test_primary_key_option_on_source + post = posts(:welcome) + category = categories(:general) + categorization = Categorization.create!(:post_id => post.id, :named_category_name => category.name) + + assert_equal [category], post.named_categories + assert_equal [category.name], post.named_category_ids # checks when target loaded + assert_equal [category.name], post.reload.named_category_ids # checks when target no loaded + end end |