aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_through_associations_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-09-06 17:14:07 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-09-06 17:14:07 -0700
commit6a91a3307ff6556225ab8717617074cea20222e0 (patch)
tree43598080eea7d8ebae994cba7ab0cd1b3e17f4e3 /activerecord/test/cases/associations/has_many_through_associations_test.rb
parenta9da99ee5fd73b6d52c6fb443b2443cdfb262d5f (diff)
downloadrails-6a91a3307ff6556225ab8717617074cea20222e0.tar.gz
rails-6a91a3307ff6556225ab8717617074cea20222e0.tar.bz2
rails-6a91a3307ff6556225ab8717617074cea20222e0.zip
hm:t join tables may not have a primary key
Diffstat (limited to 'activerecord/test/cases/associations/has_many_through_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb18
1 files changed, 18 insertions, 0 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 508faa9437..541f649ae9 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -64,6 +64,24 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
anonbook.subscribers.map(&:id).sort
end
+ def test_no_pk_join_table_append
+ lesson = make_model 'Lesson'
+ student = make_model 'Student'
+
+ lesson_student = make_model 'LessonStudent'
+ lesson_student.table_name = 'lessons_students'
+
+ lesson_student.belongs_to :lesson, :class => lesson
+ lesson_student.belongs_to :student, :class => student
+ lesson.has_many :lesson_students, :class => lesson_student
+ lesson.has_many :students, :through => :lesson_students, :class => student
+
+ sicp = lesson.new(:name => "SICP")
+ ben = student.new(:name => "Ben Bitdiddle")
+ sicp.students << ben
+ assert sicp.save!
+ end
+
def test_pk_is_not_required_for_join
post = Post.includes(:scategories).first
post2 = Post.includes(:categories).first