aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2019-05-02 06:45:56 -0500
committerGitHub <noreply@github.com>2019-05-02 06:45:56 -0500
commitb343beba03722672b9bb827f8ce29c7c1c216406 (patch)
treeb060c274d60717b37847c1e62800eb32fed3b789 /activerecord/test
parent730a7a1b7909095dd48b9f32bbae5fd5a023fa60 (diff)
parentcce26c36cae49f0143ce2305dbf5b00cca0e53c1 (diff)
downloadrails-b343beba03722672b9bb827f8ce29c7c1c216406.tar.gz
rails-b343beba03722672b9bb827f8ce29c7c1c216406.tar.bz2
rails-b343beba03722672b9bb827f8ce29c7c1c216406.zip
Merge pull request #36131 from Shopify/fix-association-extension-module-namespace
Namespace association extension modules under the owner model
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/extension_test.rb4
-rw-r--r--activerecord/test/models/developer.rb16
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