diff options
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/extension_test.rb | 20 | ||||
-rw-r--r-- | activerecord/test/cases/autosave_association_test.rb | 8 |
2 files changed, 16 insertions, 12 deletions
diff --git a/activerecord/test/cases/associations/extension_test.rb b/activerecord/test/cases/associations/extension_test.rb index e1f5b16eca..24830a661a 100644 --- a/activerecord/test/cases/associations/extension_test.rb +++ b/activerecord/test/cases/associations/extension_test.rb @@ -29,7 +29,7 @@ class AssociationsExtensionsTest < ActiveRecord::TestCase assert_equal projects(:action_controller), developers(:david).projects_extended_by_name_and_block.find_most_recent assert_equal projects(:active_record), developers(:david).projects_extended_by_name_and_block.find_least_recent end - + def test_extension_with_scopes assert_equal comments(:greetings), posts(:welcome).comments.offset(1).find_most_recent assert_equal comments(:greetings), posts(:welcome).comments.not_again.find_most_recent @@ -52,12 +52,16 @@ class AssociationsExtensionsTest < ActiveRecord::TestCase end def test_extension_name - extension = Proc.new {} - name = :association_name - - assert_equal 'DeveloperAssociationNameAssociationExtension', Developer.send(:create_extension_modules, name, extension, []).first.name - assert_equal 'MyApplication::Business::DeveloperAssociationNameAssociationExtension', MyApplication::Business::Developer.send(:create_extension_modules, name, extension, []).first.name - assert_equal 'MyApplication::Business::DeveloperAssociationNameAssociationExtension', MyApplication::Business::Developer.send(:create_extension_modules, name, extension, []).first.name - assert_equal 'MyApplication::Business::DeveloperAssociationNameAssociationExtension', MyApplication::Business::Developer.send(:create_extension_modules, name, extension, []).first.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) end + + private + + def extension_name(model) + builder = ActiveRecord::Associations::Builder::HasMany.new(model, :association_name, {}) { } + builder.send(:wrap_block_extension) + builder.options[:extend].first.name + end end diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index dbc5d71153..b9d9d89220 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -21,19 +21,19 @@ require 'models/eye' class TestAutosaveAssociationsInGeneral < ActiveRecord::TestCase def test_autosave_should_be_a_valid_option_for_has_one - assert base.valid_keys_for_has_one_association.include?(:autosave) + assert ActiveRecord::Associations::Builder::HasOne.valid_options.include?(:autosave) end def test_autosave_should_be_a_valid_option_for_belongs_to - assert base.valid_keys_for_belongs_to_association.include?(:autosave) + assert ActiveRecord::Associations::Builder::BelongsTo.valid_options.include?(:autosave) end def test_autosave_should_be_a_valid_option_for_has_many - assert base.valid_keys_for_has_many_association.include?(:autosave) + assert ActiveRecord::Associations::Builder::HasMany.valid_options.include?(:autosave) end def test_autosave_should_be_a_valid_option_for_has_and_belongs_to_many - assert base.valid_keys_for_has_and_belongs_to_many_association.include?(:autosave) + assert ActiveRecord::Associations::Builder::HasAndBelongsToMany.valid_options.include?(:autosave) end def test_should_not_add_the_same_callbacks_multiple_times_for_has_one |