diff options
author | Xavier Noria <fxn@hashref.com> | 2010-08-20 17:18:57 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-08-20 17:18:57 +0200 |
commit | 0c75ec51a9b60252125534b8f9a3f6406713a957 (patch) | |
tree | 34165e93f7dd01157f77e4e70a46ec6a5bed77c8 /activerecord/test/cases/associations | |
parent | 87398e531d0bb23b30787fe26d86678dba322895 (diff) | |
parent | 2ffa50f5a9fac08e08869687006031b70322497a (diff) | |
download | rails-0c75ec51a9b60252125534b8f9a3f6406713a957.tar.gz rails-0c75ec51a9b60252125534b8f9a3f6406713a957.tar.bz2 rails-0c75ec51a9b60252125534b8f9a3f6406713a957.zip |
Merge remote branch 'rails/master'
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/extension_test.rb | 13 | ||||
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 19 |
2 files changed, 24 insertions, 8 deletions
diff --git a/activerecord/test/cases/associations/extension_test.rb b/activerecord/test/cases/associations/extension_test.rb index e9240de673..efaab8569e 100644 --- a/activerecord/test/cases/associations/extension_test.rb +++ b/activerecord/test/cases/associations/extension_test.rb @@ -46,16 +46,13 @@ class AssociationsExtensionsTest < ActiveRecord::TestCase assert_equal projects(:action_controller), david.projects_extended_by_name.find_most_recent end + def test_extension_name + extension = Proc.new {} + name = :association_name - 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 '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 end - - end diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 7e10a8ceeb..63fc15bca3 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -13,6 +13,8 @@ require 'models/reader' require 'models/tagging' require 'models/invoice' require 'models/line_item' +require 'models/car' +require 'models/bulb' class HasManyAssociationsTestForCountWithFinderSql < ActiveRecord::TestCase class Invoice < ActiveRecord::Base @@ -47,6 +49,23 @@ class HasManyAssociationsTest < ActiveRecord::TestCase Client.destroyed_client_ids.clear end + def test_create_from_association_should_respect_default_scope + car = Car.create(:name => 'honda') + assert_equal 'honda', car.name + + bulb = Bulb.create + assert_equal 'defaulty', bulb.name + + bulb = car.bulbs.build + assert_equal 'defaulty', bulb.name + + bulb = car.bulbs.create + assert_equal 'defaulty', bulb.name + + bulb = car.bulbs.create(:name => 'exotic') + assert_equal 'exotic', bulb.name + end + def test_create_resets_cached_counters person = Person.create!(:first_name => 'tenderlove') post = Post.first |