diff options
author | Eloy Duran <eloy.de.enige@gmail.com> | 2009-12-31 14:03:04 +0100 |
---|---|---|
committer | Eloy Duran <eloy.de.enige@gmail.com> | 2010-01-07 13:19:48 +0100 |
commit | f82adc7c5addb4f9bf6b9cb3f1fcf3fb47505e53 (patch) | |
tree | b71e7a9af8a7742f07bcd3d5d65e50bdc3f94bb2 /activerecord/test/cases | |
parent | 1afa9fa5a973734852bd7a9d20a534355c221098 (diff) | |
download | rails-f82adc7c5addb4f9bf6b9cb3f1fcf3fb47505e53.tar.gz rails-f82adc7c5addb4f9bf6b9cb3f1fcf3fb47505e53.tar.bz2 rails-f82adc7c5addb4f9bf6b9cb3f1fcf3fb47505e53.zip |
Add AssociationReflection#collection_association? which returns true if it's for a has_many or has_and_belongs_to_many association.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/reflection_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb index 211cf1d449..f35bd547c6 100644 --- a/activerecord/test/cases/reflection_test.rb +++ b/activerecord/test/cases/reflection_test.rb @@ -4,6 +4,7 @@ require 'models/customer' require 'models/company' require 'models/company_in_module' require 'models/subscriber' +require 'models/ship' require 'models/pirate' require 'models/price_estimate' @@ -194,6 +195,14 @@ class ReflectionTest < ActiveRecord::TestCase assert_kind_of ActiveRecord::Reflection::ThroughReflection, Subscriber.reflect_on_association(:books) end + def test_collection_association? + assert Pirate.reflect_on_association(:birds).collection_association? + assert Pirate.reflect_on_association(:parrots).collection_association? + + assert !Pirate.reflect_on_association(:ship).collection_association? + assert !Ship.reflect_on_association(:pirate).collection_association? + end + private def assert_reflection(klass, association, options) assert reflection = klass.reflect_on_association(association) |