Skip to content

Commit

Permalink
Fix the actual_foreign_key method that is returning a string instead …
Browse files Browse the repository at this point in the history
…of an array of foreign keys
  • Loading branch information
vsppedro committed May 24, 2021
1 parent f3acf5a commit d828075
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/shoulda/matchers/active_record/association_matcher.rb
Expand Up @@ -1447,7 +1447,9 @@ def primary_key_correct?(klass)
def actual_foreign_key
return unless foreign_key_reflection

if foreign_key_reflection.respond_to?(:foreign_key)
if foreign_key_reflection.options[:foreign_key]
foreign_key_reflection.options[:foreign_key]
elsif foreign_key_reflection.respond_to?(:foreign_key)
foreign_key_reflection.foreign_key
else
foreign_key_reflection.primary_key_name
Expand Down

0 comments on commit d828075

Please sign in to comment.