aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_associations_test.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-08-20 17:18:57 +0200
committerXavier Noria <fxn@hashref.com>2010-08-20 17:18:57 +0200
commit0c75ec51a9b60252125534b8f9a3f6406713a957 (patch)
tree34165e93f7dd01157f77e4e70a46ec6a5bed77c8 /activerecord/test/cases/associations/has_many_associations_test.rb
parent87398e531d0bb23b30787fe26d86678dba322895 (diff)
parent2ffa50f5a9fac08e08869687006031b70322497a (diff)
downloadrails-0c75ec51a9b60252125534b8f9a3f6406713a957.tar.gz
rails-0c75ec51a9b60252125534b8f9a3f6406713a957.tar.bz2
rails-0c75ec51a9b60252125534b8f9a3f6406713a957.zip
Merge remote branch 'rails/master'
Diffstat (limited to 'activerecord/test/cases/associations/has_many_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb19
1 files changed, 19 insertions, 0 deletions
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