diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/aggregations_test.rb | 19 | ||||
-rw-r--r-- | activerecord/test/fixtures/customer.rb | 4 |
2 files changed, 23 insertions, 0 deletions
diff --git a/activerecord/test/aggregations_test.rb b/activerecord/test/aggregations_test.rb index 8be0b20198..39adedae53 100644 --- a/activerecord/test/aggregations_test.rb +++ b/activerecord/test/aggregations_test.rb @@ -44,4 +44,23 @@ class AggregationsTest < Test::Unit::TestCase assert_equal "39", customers(:david).gps_location.latitude assert_equal "-110", customers(:david).gps_location.longitude end + + def test_reloaded_instance_refreshes_aggregations + assert_equal "35.544623640962634", customers(:david).gps_location.latitude + assert_equal "-105.9309951055148", customers(:david).gps_location.longitude + + Customer.update_all("gps_location = '24x113'") + customers(:david).reload + assert_equal '24x113', customers(:david)['gps_location'] + + assert_equal GpsLocation.new('24x113'), customers(:david).gps_location + end + + def test_gps_equality + assert GpsLocation.new('39x110') == GpsLocation.new('39x110') + end + + def test_gps_inequality + assert GpsLocation.new('39x110') != GpsLocation.new('39x111') + end end diff --git a/activerecord/test/fixtures/customer.rb b/activerecord/test/fixtures/customer.rb index c36d4d33a8..2eba052eee 100644 --- a/activerecord/test/fixtures/customer.rb +++ b/activerecord/test/fixtures/customer.rb @@ -44,4 +44,8 @@ class GpsLocation def longitude gps_location.split("x").last end + + def ==(other) + self.latitude == other.latitude && self.longitude == other.longitude + end end
\ No newline at end of file |