mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
fixed foreign key determination (http://tammer.lighthouseapp.com/projects/5807/tickets/8)
git-svn-id: https://svn.thoughtbot.com/plugins/shoulda/trunk@287 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
This commit is contained in:
parent
46f8ff2437
commit
b5251e9f2b
2 changed files with 7 additions and 2 deletions
|
@ -1,8 +1,13 @@
|
|||
Autotest.add_hook :initialize do |at|
|
||||
at.add_mapping(%r{^lib/\w.*\.rb}) do
|
||||
at.files_matching(%r{^test/*/\w.*_test\.rb})
|
||||
end
|
||||
|
||||
at.add_mapping(%r{^test/rails_root/\w.*}) do
|
||||
at.files_matching(%r{^test/*/\w.*_test\.rb})
|
||||
end
|
||||
|
||||
at.add_exception(%r{.svn})
|
||||
at.add_exception(%r{.log$})
|
||||
at.add_exception(%r{^.autotest$})
|
||||
end
|
||||
|
|
|
@ -302,7 +302,7 @@ module ThoughtBot # :nodoc:
|
|||
elsif reflection.options[:as]
|
||||
fk = reflection.options[:as].to_s.foreign_key
|
||||
else
|
||||
fk = klass.name.foreign_key
|
||||
fk = reflection.primary_key_name
|
||||
end
|
||||
associated_klass = (reflection.options[:class_name] || association.to_s.classify).constantize
|
||||
assert associated_klass.column_names.include?(fk.to_s), "#{associated_klass.name} does not have a #{fk} foreign key."
|
||||
|
@ -367,7 +367,7 @@ module ThoughtBot # :nodoc:
|
|||
|
||||
unless reflection.options[:polymorphic]
|
||||
associated_klass = (reflection.options[:class_name] || association.to_s.classify).constantize
|
||||
fk = reflection.options[:foreign_key] || associated_klass.name.foreign_key
|
||||
fk = reflection.options[:foreign_key] || reflection.primary_key_name
|
||||
assert klass.column_names.include?(fk.to_s), "#{klass.name} does not have a #{fk} foreign key."
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue