Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
3cce7628
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,发现更多精彩内容 >>
提交
3cce7628
编写于
9月 03, 2014
作者:
A
Akira Matsuda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reset ActiveRecord::SchemaDumper.ignore_tables value after changed in tests
上级
268a55f5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
26 deletion
+21
-26
activerecord/test/cases/schema_dumper_test.rb
activerecord/test/cases/schema_dumper_test.rb
+12
-26
activerecord/test/support/schema_dumping_helper.rb
activerecord/test/support/schema_dumping_helper.rb
+9
-0
未找到文件。
activerecord/test/cases/schema_dumper_test.rb
浏览文件 @
3cce7628
...
...
@@ -2,6 +2,7 @@
require
'support/schema_dumping_helper'
class
SchemaDumperTest
<
ActiveRecord
::
TestCase
include
SchemaDumpingHelper
self
.
use_transactional_fixtures
=
false
setup
do
...
...
@@ -10,9 +11,11 @@ class SchemaDumperTest < ActiveRecord::TestCase
def
standard_dump
@stream
=
StringIO
.
new
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
[]
old_ignore_tables
,
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
ActiveRecord
::
SchemaDumper
.
ignore_tables
,
[]
ActiveRecord
::
SchemaDumper
.
dump
(
ActiveRecord
::
Base
.
connection
,
@stream
)
@stream
.
string
ensure
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
old_ignore_tables
end
def
test_dump_schema_information_outputs_lexically_ordered_versions
...
...
@@ -90,20 +93,12 @@ def test_no_dump_errors
end
def
test_schema_dump_includes_not_null_columns
stream
=
StringIO
.
new
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
[
/^[^r]/
]
ActiveRecord
::
SchemaDumper
.
dump
(
ActiveRecord
::
Base
.
connection
,
stream
)
output
=
stream
.
string
output
=
dump_all_table_schema
([
/^[^r]/
])
assert_match
%r{null: false}
,
output
end
def
test_schema_dump_includes_limit_constraint_for_integer_columns
stream
=
StringIO
.
new
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
[
/^(?!integer_limits)/
]
ActiveRecord
::
SchemaDumper
.
dump
(
ActiveRecord
::
Base
.
connection
,
stream
)
output
=
stream
.
string
output
=
dump_all_table_schema
([
/^(?!integer_limits)/
])
if
current_adapter?
(
:PostgreSQLAdapter
)
assert_match
%r{c_int_1.*limit: 2}
,
output
...
...
@@ -150,22 +145,14 @@ def test_schema_dump_includes_limit_constraint_for_integer_columns
end
def
test_schema_dump_with_string_ignored_table
stream
=
StringIO
.
new
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
[
'accounts'
]
ActiveRecord
::
SchemaDumper
.
dump
(
ActiveRecord
::
Base
.
connection
,
stream
)
output
=
stream
.
string
output
=
dump_all_table_schema
([
'accounts'
])
assert_no_match
%r{create_table "accounts"}
,
output
assert_match
%r{create_table "authors"}
,
output
assert_no_match
%r{create_table "schema_migrations"}
,
output
end
def
test_schema_dump_with_regexp_ignored_table
stream
=
StringIO
.
new
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
[
/^account/
]
ActiveRecord
::
SchemaDumper
.
dump
(
ActiveRecord
::
Base
.
connection
,
stream
)
output
=
stream
.
string
output
=
dump_all_table_schema
([
/^account/
])
assert_no_match
%r{create_table "accounts"}
,
output
assert_match
%r{create_table "authors"}
,
output
assert_no_match
%r{create_table "schema_migrations"}
,
output
...
...
@@ -173,10 +160,12 @@ def test_schema_dump_with_regexp_ignored_table
def
test_schema_dump_illegal_ignored_table_value
stream
=
StringIO
.
new
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
[
5
]
old_ignore_tables
,
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
ActiveRecord
::
SchemaDumper
.
ignore_tables
,
[
5
]
assert_raise
(
StandardError
)
do
ActiveRecord
::
SchemaDumper
.
dump
(
ActiveRecord
::
Base
.
connection
,
stream
)
end
ensure
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
old_ignore_tables
end
def
test_schema_dumps_index_columns_in_right_order
...
...
@@ -245,10 +234,7 @@ def test_schema_dumps_index_type
end
def
test_schema_dump_includes_decimal_options
stream
=
StringIO
.
new
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
[
/^[^n]/
]
ActiveRecord
::
SchemaDumper
.
dump
(
ActiveRecord
::
Base
.
connection
,
stream
)
output
=
stream
.
string
output
=
dump_all_table_schema
([
/^[^n]/
])
assert_match
%r{precision: 3,[[:space:]]+scale: 2,[[:space:]]+default: 2.78}
,
output
end
...
...
activerecord/test/support/schema_dumping_helper.rb
浏览文件 @
3cce7628
...
...
@@ -8,4 +8,13 @@ def dump_table_schema(table, connection = ActiveRecord::Base.connection)
ensure
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
old_ignore_tables
end
def
dump_all_table_schema
(
ignore_tables
)
old_ignore_tables
,
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
ActiveRecord
::
SchemaDumper
.
ignore_tables
,
ignore_tables
stream
=
StringIO
.
new
ActiveRecord
::
SchemaDumper
.
dump
(
ActiveRecord
::
Base
.
connection
,
stream
)
stream
.
string
ensure
ActiveRecord
::
SchemaDumper
.
ignore_tables
=
old_ignore_tables
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录