Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
5c8da16a
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5c8da16a
编写于
1月 11, 2012
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
decoupling more tests from AR::Base
上级
ee4e2424
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
24 deletion
+45
-24
activerecord/test/cases/migration/change_schema_test.rb
activerecord/test/cases/migration/change_schema_test.rb
+45
-0
activerecord/test/cases/migration_test.rb
activerecord/test/cases/migration_test.rb
+0
-24
未找到文件。
activerecord/test/cases/migration/change_schema_test.rb
浏览文件 @
5c8da16a
...
@@ -17,6 +17,51 @@ def teardown
...
@@ -17,6 +17,51 @@ def teardown
ActiveRecord
::
Base
.
primary_key_prefix_type
=
nil
ActiveRecord
::
Base
.
primary_key_prefix_type
=
nil
end
end
def
test_remove_nonexistent_index
skip
"not supported on openbase"
if
current_adapter?
(
:OpenBaseAdapter
)
connection
.
create_table
table_name
do
|
t
|
t
.
column
:foo
,
:string
,
:limit
=>
100
t
.
column
:bar
,
:string
,
:limit
=>
100
end
# we do this by name, so OpenBase is a wash as noted above
assert_raise
(
ArgumentError
)
{
connection
.
remove_index
(
table_name
,
"no_such_index"
)
}
end
def
test_add_index_length_limit
connection
.
create_table
table_name
do
|
t
|
t
.
column
:foo
,
:string
,
:limit
=>
100
t
.
column
:bar
,
:string
,
:limit
=>
100
end
good_index_name
=
'x'
*
connection
.
index_name_length
too_long_index_name
=
good_index_name
+
'x'
assert_raises
(
ArgumentError
)
{
connection
.
add_index
(
table_name
,
"foo"
,
:name
=>
too_long_index_name
)
}
refute
connection
.
index_name_exists?
(
table_name
,
too_long_index_name
,
false
)
connection
.
add_index
(
table_name
,
"foo"
,
:name
=>
good_index_name
)
assert
connection
.
index_name_exists?
(
table_name
,
good_index_name
,
false
)
connection
.
remove_index
(
table_name
,
:name
=>
good_index_name
)
end
def
test_index_symbol_names
connection
.
create_table
:testings
do
|
t
|
t
.
column
:foo
,
:string
,
:limit
=>
100
t
.
column
:bar
,
:string
,
:limit
=>
100
end
connection
.
add_index
table_name
,
:foo
,
:name
=>
:symbol_index_name
assert
connection
.
index_exists?
(
table_name
,
:foo
,
:name
=>
:symbol_index_name
)
connection
.
remove_index
table_name
,
:name
=>
:symbol_index_name
refute
connection
.
index_exists?
(
table_name
,
:foo
,
:name
=>
:symbol_index_name
)
end
def
test_index_exists
def
test_index_exists
connection
.
create_table
:testings
do
|
t
|
connection
.
create_table
:testings
do
|
t
|
t
.
column
:foo
,
:string
,
:limit
=>
100
t
.
column
:foo
,
:string
,
:limit
=>
100
...
...
activerecord/test/cases/migration_test.rb
浏览文件 @
5c8da16a
...
@@ -62,30 +62,6 @@ def teardown
...
@@ -62,30 +62,6 @@ def teardown
Person
.
reset_column_information
Person
.
reset_column_information
end
end
def
test_index_symbol_names
assert_nothing_raised
{
Person
.
connection
.
add_index
:people
,
:primary_contact_id
,
:name
=>
:symbol_index_name
}
assert
Person
.
connection
.
index_exists?
(
:people
,
:primary_contact_id
,
:name
=>
:symbol_index_name
)
assert_nothing_raised
{
Person
.
connection
.
remove_index
:people
,
:name
=>
:symbol_index_name
}
assert
!
Person
.
connection
.
index_exists?
(
:people
,
:primary_contact_id
,
:name
=>
:symbol_index_name
)
end
def
test_add_index_length_limit
good_index_name
=
'x'
*
Person
.
connection
.
index_name_length
too_long_index_name
=
good_index_name
+
'x'
assert_raise
(
ArgumentError
)
{
Person
.
connection
.
add_index
(
"people"
,
"first_name"
,
:name
=>
too_long_index_name
)
}
assert
!
Person
.
connection
.
index_name_exists?
(
"people"
,
too_long_index_name
,
false
)
assert_nothing_raised
{
Person
.
connection
.
add_index
(
"people"
,
"first_name"
,
:name
=>
good_index_name
)
}
assert
Person
.
connection
.
index_name_exists?
(
"people"
,
good_index_name
,
false
)
Person
.
connection
.
remove_index
(
"people"
,
:name
=>
good_index_name
)
end
def
test_remove_nonexistent_index
skip
"not supported on openbase"
if
current_adapter?
(
:OpenBaseAdapter
)
# we do this by name, so OpenBase is a wash as noted above
assert_raise
(
ArgumentError
)
{
Person
.
connection
.
remove_index
(
"people"
,
"no_such_index"
)
}
end
def
test_rename_index
def
test_rename_index
skip
"not supported on openbase"
if
current_adapter?
(
:OpenBaseAdapter
)
skip
"not supported on openbase"
if
current_adapter?
(
:OpenBaseAdapter
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录