fixing db
git-svn-id: https://svn.thoughtbot.com/plugins/shoulda/trunk@191 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
This commit is contained in:
parent
0f194fb28a
commit
8c9c760a26
2
Rakefile
2
Rakefile
|
@ -2,7 +2,7 @@ require 'rake'
|
|||
require 'rake/testtask'
|
||||
require 'rake/rdoctask'
|
||||
|
||||
require 'lib/tasks/list_tests.rb'
|
||||
#require 'tasks/list_tests.rake'
|
||||
|
||||
# Test::Unit::UI::VERBOSE
|
||||
|
||||
|
|
|
@ -317,14 +317,14 @@ module ThoughtBot # :nodoc:
|
|||
#
|
||||
# should_belong_to :parent
|
||||
def should_belong_to(*associations)
|
||||
get_options!(associations)
|
||||
fk = get_options!(associations, :foreign_key)
|
||||
klass = model_class
|
||||
associations.each do |association|
|
||||
should "belong_to #{association}" do
|
||||
reflection = klass.reflect_on_association(association)
|
||||
assert reflection, "#{klass.name} does not have any relationship to #{association}"
|
||||
assert_equal :belongs_to, reflection.macro
|
||||
fk = reflection.options[:foreign_key] || "#{association}_id"
|
||||
fk ||= (reflection.options[:foreign_key] || "#{association}_id")
|
||||
assert klass.column_names.include?(fk), "#{klass.name} does not have a #{fk} foreign key."
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class CreateTaggings < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :taggings do |t|
|
||||
t.column :user_id, :integer
|
||||
t.column :post_id, :integer
|
||||
t.column :tag_id, :integer
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,6 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|||
class TaggingTest < Test::Unit::TestCase
|
||||
load_all_fixtures
|
||||
|
||||
should_belong_to :post
|
||||
should_belong_to :post, :foreign_key
|
||||
should_belong_to :tag
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue