aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_associations_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-05-23 06:58:10 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-05-23 06:58:10 -0700
commit030d30d64cd8d8e376f9db25a3fe3e11358731cf (patch)
tree6584d98b81430685a2cd57b507ea507dfa7ab884 /activerecord/test/cases/associations/has_many_associations_test.rb
parent9e5b8e3831552a103b2dcf8de75fb6a2337d42ba (diff)
parentef99c1147592e91bb256952986470592ea0e5f6c (diff)
downloadrails-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/associations/has_many_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb8
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?