aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-08-01 10:53:56 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-08-01 11:02:15 -0700
commit655953cd4899bb5337bae6aad081dd1beab520eb (patch)
tree090fe56a876aeb31799cd8d6ff7aae1f8bb1a4de /activerecord
parent92ab4d6a8af7654d5d00f3d9047f17106e310118 (diff)
downloadrails-655953cd4899bb5337bae6aad081dd1beab520eb.tar.gz
rails-655953cd4899bb5337bae6aad081dd1beab520eb.tar.bz2
rails-655953cd4899bb5337bae6aad081dd1beab520eb.zip
assert that constants have been set rather than the names
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/builder/collection_association.rb6
-rw-r--r--activerecord/test/cases/associations/extension_test.rb14
2 files changed, 11 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/associations/builder/collection_association.rb b/activerecord/lib/active_record/associations/builder/collection_association.rb
index 6cce519494..076fedc1a9 100644
--- a/activerecord/lib/active_record/associations/builder/collection_association.rb
+++ b/activerecord/lib/active_record/associations/builder/collection_association.rb
@@ -12,7 +12,7 @@ module ActiveRecord::Associations::Builder
:after_add, :before_remove, :after_remove, :extend]
end
- attr_reader :block_extension, :extension_module
+ attr_reader :block_extension
def initialize(*args, &extension)
super(*args)
@@ -20,7 +20,7 @@ module ActiveRecord::Associations::Builder
end
def build
- wrap_block_extension
+ define_extensions(model)
reflection = super
reflection
end
@@ -30,7 +30,7 @@ module ActiveRecord::Associations::Builder
CALLBACKS.each { |callback_name| define_callback(model, callback_name) }
end
- def wrap_block_extension
+ def define_extensions(model)
if block_extension
@extension_module = mod = Module.new(&block_extension)
silence_warnings do
diff --git a/activerecord/test/cases/associations/extension_test.rb b/activerecord/test/cases/associations/extension_test.rb
index da767a2a7e..b1dacaefcc 100644
--- a/activerecord/test/cases/associations/extension_test.rb
+++ b/activerecord/test/cases/associations/extension_test.rb
@@ -59,9 +59,12 @@ class AssociationsExtensionsTest < ActiveRecord::TestCase
end
def test_extension_name
- assert_equal 'DeveloperAssociationNameAssociationExtension', extension_name(Developer)
- assert_equal 'MyApplication::Business::DeveloperAssociationNameAssociationExtension', extension_name(MyApplication::Business::Developer)
- assert_equal 'MyApplication::Business::DeveloperAssociationNameAssociationExtension', extension_name(MyApplication::Business::Developer)
+ extend!(Developer)
+ extend!(MyApplication::Business::Developer)
+ extend!(MyApplication::Business::Developer)
+
+ assert Object.const_get 'DeveloperAssociationNameAssociationExtension'
+ assert MyApplication::Business.const_get 'DeveloperAssociationNameAssociationExtension'
end
def test_proxy_association_after_scoped
@@ -72,9 +75,8 @@ class AssociationsExtensionsTest < ActiveRecord::TestCase
private
- def extension_name(model)
+ def extend!(model)
builder = ActiveRecord::Associations::Builder::HasMany.new(model, :association_name, nil, {}) { }
- builder.send(:wrap_block_extension)
- builder.extension_module.name
+ builder.define_extensions(model)
end
end