diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-27 10:34:32 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-27 10:34:32 -0300 |
commit | 3067aee91fa4eaaa82a58a79d32c72fd9b9b3f51 (patch) | |
tree | 2dbd45d4f649c9864c5055afa0e70885b91ddaa7 /activerecord/test/cases/associations | |
parent | cd5918f78c3e7ee60bcfda193c18666eb43871a7 (diff) | |
parent | 8570f9391d725afae1f3d60bfc5536afc46733b5 (diff) | |
download | rails-3067aee91fa4eaaa82a58a79d32c72fd9b9b3f51.tar.gz rails-3067aee91fa4eaaa82a58a79d32c72fd9b9b3f51.tar.bz2 rails-3067aee91fa4eaaa82a58a79d32c72fd9b9b3f51.zip |
Merge pull request #15358 from arthurnn/redefine_habtm_fix
Fix redefine a has_and_belongs_to_many inside inherited class
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index 878f1877db..8d8201ddae 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -70,6 +70,14 @@ class DeveloperWithSymbolsForKeys < ActiveRecord::Base :foreign_key => "developer_id" end +class SubDeveloper < Developer + self.table_name = 'developers' + has_and_belongs_to_many :special_projects, + :join_table => 'developers_projects', + :foreign_key => "project_id", + :association_foreign_key => "developer_id" +end + class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase fixtures :accounts, :companies, :categories, :posts, :categories_posts, :developers, :projects, :developers_projects, :parrots, :pirates, :parrots_pirates, :treasures, :price_estimates, :tags, :taggings @@ -814,7 +822,7 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase assert_equal [], Pirate.where(id: redbeard.id) end - test "has and belongs to many associations on new records use null relations" do + def test_has_and_belongs_to_many_associations_on_new_records_use_null_relations projects = Developer.new.projects assert_no_queries do assert_equal [], projects @@ -860,4 +868,10 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase assert_includes magazine.articles, article end + + def test_redefine_habtm + child = SubDeveloper.new("name" => "Aredridel") + child.special_projects << SpecialProject.new("name" => "Special Project") + assert_equal true, child.save + end end |