From 670f154afcc6363ebcb415d15f589140ebb438ea Mon Sep 17 00:00:00 2001 From: Mauro George Date: Wed, 17 Jun 2015 19:15:52 -0300 Subject: [PATCH] Add note about polymorphic associations on have_many [ci skip] --- .../active_record/association_matcher.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/shoulda/matchers/active_record/association_matcher.rb b/lib/shoulda/matchers/active_record/association_matcher.rb index aaf1d529..a55807cd 100644 --- a/lib/shoulda/matchers/active_record/association_matcher.rb +++ b/lib/shoulda/matchers/active_record/association_matcher.rb @@ -276,6 +276,23 @@ module Shoulda # should have_many(:friends) # end # + # Note that polymorphic associations are automatically detected and do not + # need any qualifiers: + # + # class Person < ActiveRecord::Base + # has_many :pictures, as: :imageable + # end + # + # # RSpec + # describe Person do + # it { should have_many(:pictures) } + # end + # + # # Test::Unit + # class PersonTest < ActiveSupport::TestCase + # should have_many(:pictures) + # end + # # #### Qualifiers # # ##### conditions