diff options
author | keepcosmos <keepcosmos@gmail.com> | 2015-05-26 22:02:41 +0900 |
---|---|---|
committer | keepcosmos <keepcosmos@gmail.com> | 2015-05-26 22:06:53 +0900 |
commit | 995a473f0c3ed1804778b163e0b7d02d410568a5 (patch) | |
tree | 2411dd71cbf40cbcfb2d7a67f50feea07e6b644e /activerecord/test | |
parent | 31cc1c2ef320f554120a1736eaf087aca19464a6 (diff) | |
download | rails-995a473f0c3ed1804778b163e0b7d02d410568a5.tar.gz rails-995a473f0c3ed1804778b163e0b7d02d410568a5.tar.bz2 rails-995a473f0c3ed1804778b163e0b7d02d410568a5.zip |
add `extend` option on `has_and_belongs_to_many`.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb | 15 |
1 files changed, 15 insertions, 0 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 2ec2bb1754..e584c94ad8 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 @@ -83,6 +83,16 @@ class DeveloperWithSymbolClassName < Developer has_and_belongs_to_many :projects, class_name: :ProjectWithSymbolsForKeys end +class DeveloperWithExtendOption < Developer + module NamedExtension + def category + 'sns' + end + end + + has_and_belongs_to_many :projects, extend: NamedExtension +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, :computers @@ -577,6 +587,11 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase assert_equal developers(:poor_jamis), projects(:active_record).developers.where("salary < 10000").first end + def test_association_with_extend_option + eponine = DeveloperWithExtendOption.create(name: 'Eponine') + assert_equal 'sns', eponine.projects.category + end + def test_replace_with_less david = developers(:david) david.projects = [projects(:action_controller)] |