forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test for has_many_through associations failing to crea…
…te join models This commit adds a test that demonstrates a regression in has_many_through associations where multiple has_many_through associations associate the same parent with the same child relation. The regression is ultimately caused by rails/rails@0d38f2a, which avoids saving a through association target if we expect the target to be persisted by another (direct) association. The problem is that if we have multiple has_many_through associations that associate the same parent with the same child, we will autosave the first set of associations from the parent, but avoid saving the through target a second time (once it's persisted by the first association), and fail to create the join model for the second association chain.
- Loading branch information
1 parent
b680ec7
commit 4199eeb
Showing
8 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
class Enrollment < ActiveRecord::Base | ||
belongs_to :program | ||
belongs_to :member, class_name: "SimpleMember" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
class Program < ActiveRecord::Base | ||
has_many :enrollments | ||
has_many :members, through: :enrollments, class_name: "SimpleMember" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
class ProgramOffering < ActiveRecord::Base | ||
belongs_to :club | ||
belongs_to :program | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters