public
Rubygem
Fork of thoughtbot/shoulda
Description: Makes tests easy on the fingers and the eyes
Homepage: http://www.thoughtbot.com/projects/shoulda
Clone URL: git://github.com/technicalpickles/shoulda.git
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
tsaleh (author)
Mon Jan 21 06:30:10 -0800 2008
commit  b5251e9f2b641c75de16c04e732ee00791672ace
tree    7660d72e85839c0041e14a76aba0e30379c11334
parent  46f8ff243700e15bc6c4b1b08a4494ba7c9559c9
...
1
 
 
 
 
2
3
4
5
6
7
 
8
...
1
2
3
4
5
6
7
8
9
10
11
12
13
0
@@ -1,8 +1,13 @@
0
 Autotest.add_hook :initialize do |at|
0
+ at.add_mapping(%r{^lib/\w.*\.rb}) do
0
+ at.files_matching(%r{^test/*/\w.*_test\.rb})
0
+ end
0
+
0
   at.add_mapping(%r{^test/rails_root/\w.*}) do
0
     at.files_matching(%r{^test/*/\w.*_test\.rb})
0
   end
0
 
0
   at.add_exception(%r{.svn})
0
   at.add_exception(%r{.log$})
0
+ at.add_exception(%r{^.autotest$})
0
 end
...
302
303
304
305
 
306
307
308
...
367
368
369
370
 
371
372
373
...
302
303
304
 
305
306
307
308
...
367
368
369
 
370
371
372
373
0
@@ -302,7 +302,7 @@ module ThoughtBot # :nodoc:
0
               elsif reflection.options[:as]
0
                 fk = reflection.options[:as].to_s.foreign_key
0
               else
0
- fk = klass.name.foreign_key
0
+ fk = reflection.primary_key_name
0
               end
0
               associated_klass = (reflection.options[:class_name] || association.to_s.classify).constantize
0
               assert associated_klass.column_names.include?(fk.to_s), "#{associated_klass.name} does not have a #{fk} foreign key."
0
@@ -367,7 +367,7 @@ module ThoughtBot # :nodoc:
0
 
0
             unless reflection.options[:polymorphic]
0
               associated_klass = (reflection.options[:class_name] || association.to_s.classify).constantize
0
- fk = reflection.options[:foreign_key] || associated_klass.name.foreign_key
0
+ fk = reflection.options[:foreign_key] || reflection.primary_key_name
0
               assert klass.column_names.include?(fk.to_s), "#{klass.name} does not have a #{fk} foreign key."
0
             end
0
           end

Comments

    No one has commented yet.