aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/reflection_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-07-27 18:21:29 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-07-27 19:25:14 -0300
commitf4d818d51e64a025f78fca15fdae2391ed072656 (patch)
tree67fc2a0868bb4fc2c333fae88fffae340661681d /activerecord/test/cases/reflection_test.rb
parentc01810dbec7dc4112c0f8b9bd78709c6db9a3e2d (diff)
downloadrails-f4d818d51e64a025f78fca15fdae2391ed072656.tar.gz
rails-f4d818d51e64a025f78fca15fdae2391ed072656.tar.bz2
rails-f4d818d51e64a025f78fca15fdae2391ed072656.zip
Revert "Removing composed_of from ActiveRecord."
This reverts commit 14fc8b34521f8354a17e50cd11fa3f809e423592. Reason: we need to discuss a better path from this removal. Conflicts: activerecord/lib/active_record/reflection.rb activerecord/test/cases/base_test.rb activerecord/test/models/developer.rb
Diffstat (limited to 'activerecord/test/cases/reflection_test.rb')
-rw-r--r--activerecord/test/cases/reflection_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb
index 51f07b6a2f..c803b93746 100644
--- a/activerecord/test/cases/reflection_test.rb
+++ b/activerecord/test/cases/reflection_test.rb
@@ -83,6 +83,30 @@ class ReflectionTest < ActiveRecord::TestCase
end
end
+ def test_aggregation_reflection
+ reflection_for_address = AggregateReflection.new(
+ :composed_of, :address, nil, { :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ] }, Customer
+ )
+
+ reflection_for_balance = AggregateReflection.new(
+ :composed_of, :balance, nil, { :class_name => "Money", :mapping => %w(balance amount) }, Customer
+ )
+
+ reflection_for_gps_location = AggregateReflection.new(
+ :composed_of, :gps_location, nil, { }, Customer
+ )
+
+ assert Customer.reflect_on_all_aggregations.include?(reflection_for_gps_location)
+ assert Customer.reflect_on_all_aggregations.include?(reflection_for_balance)
+ assert Customer.reflect_on_all_aggregations.include?(reflection_for_address)
+
+ assert_equal reflection_for_address, Customer.reflect_on_aggregation(:address)
+
+ assert_equal Address, Customer.reflect_on_aggregation(:address).klass
+
+ assert_equal Money, Customer.reflect_on_aggregation(:balance).klass
+ end
+
def test_reflect_on_all_autosave_associations
expected = Pirate.reflect_on_all_associations.select { |r| r.options[:autosave] }
received = Pirate.reflect_on_all_autosave_associations