diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2019-04-29 12:31:41 +0200 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2019-05-02 13:25:18 +0200 |
commit | cce26c36cae49f0143ce2305dbf5b00cca0e53c1 (patch) | |
tree | b060c274d60717b37847c1e62800eb32fed3b789 /activerecord/test | |
parent | 730a7a1b7909095dd48b9f32bbae5fd5a023fa60 (diff) | |
download | rails-cce26c36cae49f0143ce2305dbf5b00cca0e53c1.tar.gz rails-cce26c36cae49f0143ce2305dbf5b00cca0e53c1.tar.bz2 rails-cce26c36cae49f0143ce2305dbf5b00cca0e53c1.zip |
Namespace association extension modules under the owner model
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/extension_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/models/developer.rb | 16 |
2 files changed, 10 insertions, 10 deletions
diff --git a/activerecord/test/cases/associations/extension_test.rb b/activerecord/test/cases/associations/extension_test.rb index d93d787f7c..5e6e3e8ec4 100644 --- a/activerecord/test/cases/associations/extension_test.rb +++ b/activerecord/test/cases/associations/extension_test.rb @@ -70,8 +70,8 @@ class AssociationsExtensionsTest < ActiveRecord::TestCase extend!(Developer) extend!(MyApplication::Business::Developer) - assert Object.const_get "DeveloperAssociationNameAssociationExtension" - assert MyApplication::Business.const_get "DeveloperAssociationNameAssociationExtension" + assert Developer.const_get "AssociationNameAssociationExtension" + assert MyApplication::Business::Developer.const_get "AssociationNameAssociationExtension" end def test_proxy_association_after_scoped diff --git a/activerecord/test/models/developer.rb b/activerecord/test/models/developer.rb index c6574cf6e7..92d01ba338 100644 --- a/activerecord/test/models/developer.rb +++ b/activerecord/test/models/developer.rb @@ -2,13 +2,13 @@ require "ostruct" -module DeveloperProjectsAssociationExtension2 - def find_least_recent - order("id ASC").first +class Developer < ActiveRecord::Base + module ProjectsAssociationExtension2 + def find_least_recent + order("id ASC").first + end end -end -class Developer < ActiveRecord::Base self.ignored_columns = %w(first_name last_name) has_and_belongs_to_many :projects do @@ -24,19 +24,19 @@ class Developer < ActiveRecord::Base has_and_belongs_to_many :shared_computers, class_name: "Computer" has_and_belongs_to_many :projects_extended_by_name, - -> { extending(DeveloperProjectsAssociationExtension) }, + -> { extending(ProjectsAssociationExtension) }, class_name: "Project", join_table: "developers_projects", association_foreign_key: "project_id" has_and_belongs_to_many :projects_extended_by_name_twice, - -> { extending(DeveloperProjectsAssociationExtension, DeveloperProjectsAssociationExtension2) }, + -> { extending(ProjectsAssociationExtension, ProjectsAssociationExtension2) }, class_name: "Project", join_table: "developers_projects", association_foreign_key: "project_id" has_and_belongs_to_many :projects_extended_by_name_and_block, - -> { extending(DeveloperProjectsAssociationExtension) }, + -> { extending(ProjectsAssociationExtension) }, class_name: "Project", join_table: "developers_projects", association_foreign_key: "project_id" do |