aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-01-01 05:20:00 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-01-01 05:26:35 +0900
commitbde0041f0a47a6b252852d7c49f4d3f75a29bc70 (patch)
treec52e8e4a15e15a98f68db843286cb364ac966545 /activerecord
parente4c6a84fb15c7856b66d8fb478d396d68ba50c34 (diff)
downloadrails-bde0041f0a47a6b252852d7c49f4d3f75a29bc70.tar.gz
rails-bde0041f0a47a6b252852d7c49f4d3f75a29bc70.tar.bz2
rails-bde0041f0a47a6b252852d7c49f4d3f75a29bc70.zip
Add test case for `collection_singular_ids` with symbol primary keys
This is a regression test for #27864.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb8
-rw-r--r--activerecord/test/models/contract.rb2
2 files changed, 9 insertions, 1 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 046020e310..7c9c9e81ab 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -869,6 +869,14 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
assert_equal [dev], company.developers
end
+ def test_collection_singular_ids_setter_with_required_type_cast
+ company = companies(:rails_core)
+ dev = Developer.first
+
+ company.developer_ids = [dev.id.to_s]
+ assert_equal [dev], company.developers
+ end
+
def test_collection_singular_ids_setter_with_string_primary_keys
assert_nothing_raised do
book = books(:awdr)
diff --git a/activerecord/test/models/contract.rb b/activerecord/test/models/contract.rb
index 9454217e8d..f273badd85 100644
--- a/activerecord/test/models/contract.rb
+++ b/activerecord/test/models/contract.rb
@@ -2,7 +2,7 @@
class Contract < ActiveRecord::Base
belongs_to :company
- belongs_to :developer
+ belongs_to :developer, primary_key: :id
belongs_to :firm, foreign_key: "company_id"
before_save :hi