aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-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