2005-03-10 09:24:28 -05:00
require 'abstract_unit'
class ActiveSchemaTest < Test :: Unit :: TestCase
def setup
ActiveRecord :: ConnectionAdapters :: MysqlAdapter . class_eval do
alias_method :real_execute , :execute
def execute ( sql , name = nil ) return sql end
2007-05-25 20:20:37 -04:00
end
2005-03-10 09:24:28 -05:00
end
2007-05-25 20:20:37 -04:00
2005-03-10 09:24:28 -05:00
def teardown
ActiveRecord :: ConnectionAdapters :: MysqlAdapter . send ( :alias_method , :execute , :real_execute )
end
def test_drop_table
2007-10-16 01:06:33 -04:00
assert_equal " DROP TABLE `people` " , drop_table ( :people )
2005-03-10 09:24:28 -05:00
end
2007-05-25 20:20:37 -04:00
if current_adapter? ( :MysqlAdapter )
def test_create_mysql_database_with_encoding
assert_equal " CREATE DATABASE `matt` DEFAULT CHARACTER SET `utf8` " , create_database ( :matt )
assert_equal " CREATE DATABASE `aimonetti` DEFAULT CHARACTER SET `latin1` " , create_database ( :aimonetti , { :charset = > 'latin1' } )
assert_equal " CREATE DATABASE `matt_aimonetti` DEFAULT CHARACTER SET `big5` COLLATE `big5_chinese_ci` " , create_database ( :matt_aimonetti , { :charset = > :big5 , :collation = > :big5_chinese_ci } )
end
end
2005-03-10 09:24:28 -05:00
def test_add_column
2007-10-16 01:06:33 -04:00
assert_equal " ALTER TABLE `people` ADD `last_name` varchar(255) " , add_column ( :people , :last_name , :string )
2005-03-10 09:24:28 -05:00
end
2007-05-25 20:20:37 -04:00
2005-03-10 09:24:28 -05:00
def test_add_column_with_limit
2007-10-16 01:06:33 -04:00
assert_equal " ALTER TABLE `people` ADD `key` varchar(32) " , add_column ( :people , :key , :string , :limit = > 32 )
2005-03-10 09:24:28 -05:00
end
2007-05-25 20:20:37 -04:00
2005-03-10 09:24:28 -05:00
private
def method_missing ( method_symbol , * arguments )
ActiveRecord :: Base . connection . send ( method_symbol , * arguments )
end
2007-05-25 20:20:37 -04:00
end