renaming create_model_table to create_table to match ActiveRecord migration API

This commit is contained in:
Dan Croak 2009-01-24 16:34:09 -05:00 committed by Joe Ferris
parent 6463037597
commit 297775ee88
2 changed files with 27 additions and 19 deletions

View File

@ -8,7 +8,7 @@ class DatabaseMatcherTest < Test::Unit::TestCase # :nodoc:
end
should "accept an existing database column" do
create_model_table 'superheros' do |table|
create_table 'superheros' do |table|
table.string :nickname
end
define_model_class 'Superhero'
@ -26,8 +26,8 @@ class DatabaseMatcherTest < Test::Unit::TestCase # :nodoc:
@matcher = has_db_column(:nickname).column_type(:string)
end
should "accept an existing column of correct type" do
create_model_table 'superheros' do |table|
should "accept a column of correct type" do
create_table 'superheros' do |table|
table.string :nickname
end
define_model_class 'Superhero'
@ -39,8 +39,8 @@ class DatabaseMatcherTest < Test::Unit::TestCase # :nodoc:
assert_rejects @matcher, Superhero.new
end
should "reject a column with the correct name but wrong type" do
create_model_table 'superheros' do |table|
should "reject a column of wrong type" do
create_table 'superheros' do |table|
table.integer :nickname
end
define_model_class 'Superhero'
@ -53,16 +53,16 @@ class DatabaseMatcherTest < Test::Unit::TestCase # :nodoc:
@matcher = has_db_column(:money).precision(15)
end
should "accept an existing database column with correct precision" do
create_model_table 'superheros' do |table|
should "accept a column of correct precision" do
create_table 'superheros' do |table|
table.decimal :money, :precision => 15
end
define_model_class 'Superhero'
assert_accepts @matcher, Superhero.new
end
should "reject a column with the wrong precision" do
create_model_table 'superheros' do |table|
should "reject a column of wrong precision" do
create_table 'superheros' do |table|
table.decimal :money, :precision => 30
end
define_model_class 'Superhero'
@ -76,14 +76,18 @@ class DatabaseMatcherTest < Test::Unit::TestCase # :nodoc:
end
should "accept a column of correct limit" do
db_column = DatabaseColumn.new(:email, :string, :limit => 255)
build_model_class :superhero, db_column
create_table 'superheros' do |table|
table.string :email, :limit => 255
end
define_model_class 'Superhero'
assert_accepts @matcher, Superhero.new
end
should "reject a column of wrong limit" do
db_column = DatabaseColumn.new(:email, :string, :limit => 500)
build_model_class :superhero, db_column
create_table 'superheros' do |table|
table.string :email, :limit => 500
end
define_model_class 'Superhero'
assert_rejects @matcher, Superhero.new
end
end
@ -94,14 +98,18 @@ class DatabaseMatcherTest < Test::Unit::TestCase # :nodoc:
end
should "accept a column of correct default" do
db_column = DatabaseColumn.new(:admin, :boolean, :default => false)
build_model_class :superhero, db_column
create_table 'superheros' do |table|
table.boolean :admin, :default => false
end
define_model_class 'Superhero'
assert_accepts @matcher, Superhero.new
end
should "reject a column of wrong default" do
db_column = DatabaseColumn.new(:admin, :boolean, :default => true)
build_model_class :superhero, db_column
create_table 'superheros' do |table|
table.boolean :admin, :default => true
end
define_model_class 'Superhero'
assert_rejects @matcher, Superhero.new
end
end

View File

@ -1,5 +1,5 @@
class Test::Unit::TestCase
def create_model_table(table_name, &block)
def create_table(table_name, &block)
connection = ActiveRecord::Base.connection
begin
@ -29,7 +29,7 @@ class Test::Unit::TestCase
class_name = name.to_s.pluralize.classify
table_name = class_name.tableize
create_model_table(table_name) do |table|
create_table(table_name) do |table|
columns.each do |name, type|
table.column name, type
end