Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

assert that constants have been set rather than the names

  • Loading branch information...
commit 655953cd4899bb5337bae6aad081dd1beab520eb 1 parent 92ab4d6
@tenderlove tenderlove authored
View
6 activerecord/lib/active_record/associations/builder/collection_association.rb
@@ -12,7 +12,7 @@ def valid_options
: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 @@ def initialize(*args, &extension)
end
def build
- wrap_block_extension
+ define_extensions(model)
reflection = super
reflection
end
@@ -30,7 +30,7 @@ def define_callbacks(model, reflection)
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
View
14 activerecord/test/cases/associations/extension_test.rb
@@ -59,9 +59,12 @@ def test_marshalling_named_extensions
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 @@ def test_proxy_association_after_scoped
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
Please sign in to comment.
Something went wrong with that request. Please try again.