aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-02-01 00:51:47 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-02-01 01:34:32 +0900
commit7c3da6e0030aa080fcb89af58b094ed50d861a44 (patch)
tree730791b089da821ed9918210a0d725f66480ae9a /activerecord/test/models
parent23125378673bcc606b274027666a126573e136f8 (diff)
downloadrails-7c3da6e0030aa080fcb89af58b094ed50d861a44.tar.gz
rails-7c3da6e0030aa080fcb89af58b094ed50d861a44.tar.bz2
rails-7c3da6e0030aa080fcb89af58b094ed50d861a44.zip
Add regression test for has_many through record creation
#33729 affected the behavior of the has_many through record creation. Since #33729, the intermediate reflection of simple has_many through association has `inverse_of` to the association, it causes extra through record creation, the extra through record required valid before the association record is saved. https://github.com/rails/rails/blob/23125378673bcc606b274027666a126573e136f8/activerecord/lib/active_record/associations/has_many_through_association.rb#L95-L102 I think that #33729 need to more work to care about has_many through association, that PR should be reverted to not break existing apps.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/subscription.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/test/models/subscription.rb b/activerecord/test/models/subscription.rb
index d1d5d21621..f87315fcd1 100644
--- a/activerecord/test/models/subscription.rb
+++ b/activerecord/test/models/subscription.rb
@@ -3,4 +3,6 @@
class Subscription < ActiveRecord::Base
belongs_to :subscriber, counter_cache: :books_count
belongs_to :book
+
+ validates_presence_of :subscriber_id, :book_id
end