aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/aggregations_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-10-23 17:29:42 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-10-23 17:29:42 +0000
commitc220e558be33e30a7946d3604d45ba671b2e7c31 (patch)
tree7a0ea36ef2741a900a74edec20b8a9884f7fff75 /activerecord/test/aggregations_test.rb
parent562b398fd729b05bfde4da90b91efc24dbbac49d (diff)
downloadrails-c220e558be33e30a7946d3604d45ba671b2e7c31.tar.gz
rails-c220e558be33e30a7946d3604d45ba671b2e7c31.tar.bz2
rails-c220e558be33e30a7946d3604d45ba671b2e7c31.zip
Assigning nil to a composed_of aggregate also sets its immediate value to nil. Closes #9843.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8002 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/aggregations_test.rb')
-rw-r--r--activerecord/test/aggregations_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/aggregations_test.rb b/activerecord/test/aggregations_test.rb
index 8cd4bfe481..89927e5044 100644
--- a/activerecord/test/aggregations_test.rb
+++ b/activerecord/test/aggregations_test.rb
@@ -92,4 +92,19 @@ class AggregationsTest < Test::Unit::TestCase
def test_nil_raises_error_when_allow_nil_is_false
assert_raises(NoMethodError) { customers(:david).balance = nil }
end
+
+ def test_allow_nil_address_loaded_when_only_some_attributes_are_nil
+ customers(:zaphod).address_street = nil
+ customers(:zaphod).save
+ customers(:zaphod).reload
+ assert_kind_of Address, customers(:zaphod).address
+ assert customers(:zaphod).address.street.nil?
+ end
+
+ def test_nil_assignment_results_in_nil
+ customers(:david).gps_location = GpsLocation.new('39x111')
+ assert_not_equal nil, customers(:david).gps_location
+ customers(:david).gps_location = nil
+ assert_equal nil, customers(:david).gps_location
+ end
end