diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-05-23 06:58:10 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-05-23 06:58:10 -0700 |
commit | 030d30d64cd8d8e376f9db25a3fe3e11358731cf (patch) | |
tree | 6584d98b81430685a2cd57b507ea507dfa7ab884 /activerecord/test/cases | |
parent | 9e5b8e3831552a103b2dcf8de75fb6a2337d42ba (diff) | |
parent | ef99c1147592e91bb256952986470592ea0e5f6c (diff) | |
download | rails-030d30d64cd8d8e376f9db25a3fe3e11358731cf.tar.gz rails-030d30d64cd8d8e376f9db25a3fe3e11358731cf.tar.bz2 rails-030d30d64cd8d8e376f9db25a3fe3e11358731cf.zip |
Merge pull request #10713 from senny/10693_fix_primary_key_option_on_has_many
Fix the `:primary_key` option for `has_many` associations.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 8 |
1 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 d85570236f..058c812dca 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -1472,6 +1472,14 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal david.essays, Essay.where(writer_id: "David") end + def test_has_many_assignment_with_custom_primary_key + david = people(:david) + + assert_equal ["A Modest Proposal"], david.essays.map(&:name) + david.essays = [Essay.create!(name: "Remote Work" )] + assert_equal ["Remote Work"], david.essays.map(&:name) + end + def test_blank_custom_primary_key_on_new_record_should_not_run_queries author = Author.new assert !author.essays.loaded? |