public
Rubygem
Description: Makes tests easy on the fingers and the eyes
Homepage: http://www.thoughtbot.com/projects/shoulda
Clone URL: git://github.com/thoughtbot/shoulda.git
Fix for pluralization problem in should_belong_to [#19] [Earle Clubb, 
Anthony Caliendo]

  should_belong_to :address  # => now works as expected
rmm5t (author)
Fri Aug 08 16:00:45 -0700 2008
commit  f517592c45af8156b287bdecca81d02c2e33c383
tree    9957944d6d7676929df43a662d754582a79dfe60
parent  7fc100f0b994bb7de3b9d2d98820e08f1348d310
...
474
475
476
477
 
478
479
480
...
474
475
476
 
477
478
479
480
0
@@ -474,7 +474,7 @@ module ThoughtBot # :nodoc:
0
             assert_equal :belongs_to, reflection.macro
0
 
0
             unless reflection.options[:polymorphic]
0
- associated_klass = (reflection.options[:class_name] || association.to_s.classify).constantize
0
+ associated_klass = (reflection.options[:class_name] || association.to_s.camelize).constantize
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
...
1
2
 
3
4
...
1
2
3
4
5
0
@@ -1,4 +1,5 @@
0
 class Dog < ActiveRecord::Base
0
   belongs_to :user, :foreign_key => :owner_id
0
+ belongs_to :address
0
   has_and_belongs_to_many :fleas
0
 end
...
2
3
4
 
5
6
7
...
2
3
4
5
6
7
8
0
@@ -2,6 +2,7 @@ class CreateDogs < ActiveRecord::Migration
0
   def self.up
0
     create_table :dogs do |t|
0
       t.column :owner_id, :integer
0
+ t.column :address_id, :integer
0
     end
0
   end
0
 
...
3
4
5
 
6
7
...
3
4
5
6
7
8
0
@@ -3,5 +3,6 @@ require File.dirname(__FILE__) + '/../test_helper'
0
 class DogTest < Test::Unit::TestCase
0
   load_all_fixtures
0
   should_belong_to :user
0
+ should_belong_to :address
0
   should_have_and_belong_to_many :fleas
0
 end

Comments

    No one has commented yet.