1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00

add custom foreign key test

This commit is contained in:
Jacob Morris 2012-08-23 23:37:05 -06:00 committed by Jason Draper
parent 8a477a92bd
commit cf6452d86d

View file

@ -370,6 +370,14 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher do
Person.new.should_not @matcher
end
it "should accept an association with an existing custom foreign key" do
define_model :detail, :detailed_person_id => :integer
define_model :person do
has_one :detail, :foreign_key => :detailed_person_id
end
Person.new.should @matcher.foreign_key(:detailed_person_id)
end
it "should reject an association with a bad :as option" do
define_model :detail, :detailable_id => :integer,
:detailable_type => :string