Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
8c42d1b6
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,发现更多精彩内容 >>
提交
8c42d1b6
编写于
1月 26, 2018
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add test case for deprecated `insert_fixtures`
Since #31422, `insert_fixtures` is deprecated.
上级
a4df58a8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
5 deletion
+21
-5
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
.../lib/active_record/connection_adapters/sqlite3_adapter.rb
+5
-3
activerecord/test/cases/fixtures_test.rb
activerecord/test/cases/fixtures_test.rb
+16
-2
未找到文件。
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
浏览文件 @
8c42d1b6
...
...
@@ -367,9 +367,11 @@ def foreign_keys(table_name)
end
def
insert_fixtures
(
rows
,
table_name
)
rows
.
each
do
|
row
|
insert_fixture
(
row
,
table_name
)
end
ActiveSupport
::
Deprecation
.
warn
(
<<-
MSG
.
squish
)
`insert_fixtures` is deprecated and will be removed in the next version of Rails.
Consider using `insert_fixtures_set` for performance improvement.
MSG
insert_fixtures_set
(
table_name
=>
rows
)
end
def
insert_fixtures_set
(
fixture_set
,
tables_to_delete
=
[])
...
...
activerecord/test/cases/fixtures_test.rb
浏览文件 @
8c42d1b6
...
...
@@ -211,16 +211,30 @@ def test_no_auto_value_on_zero_is_disabled
subscription
=
ActiveSupport
::
Notifications
.
subscribe
(
"sql.active_record"
,
subscriber
)
assert_nothing_raised
do
ActiveRecord
::
Base
.
connection
.
insert_fixtures
(
fixtures
,
"aircraft"
)
ActiveRecord
::
Base
.
connection
.
insert_fixtures
_set
(
"aircraft"
=>
fixtures
)
end
expected_sql
=
"INSERT INTO `aircraft` (`id`, `name`, `wheels_count`) VALUES (DEFAULT, 'first', 2), (DEFAULT, 'second', 3)"
expected_sql
=
"INSERT INTO `aircraft` (`id`, `name`, `wheels_count`) VALUES (DEFAULT, 'first', 2), (DEFAULT, 'second', 3)
;
\n
"
assert_equal
expected_sql
,
subscriber
.
events
.
first
ensure
ActiveSupport
::
Notifications
.
unsubscribe
(
subscription
)
end
end
def
test_deprecated_insert_fixtures
fixtures
=
[
{
"name"
=>
"first"
,
"wheels_count"
=>
2
},
{
"name"
=>
"second"
,
"wheels_count"
=>
3
}
]
conn
=
ActiveRecord
::
Base
.
connection
conn
.
delete
(
"DELETE FROM aircraft"
)
assert_deprecated
do
conn
.
insert_fixtures
(
fixtures
,
"aircraft"
)
end
result
=
conn
.
select_all
(
"SELECT name, wheels_count FROM aircraft ORDER BY id"
)
assert_equal
fixtures
,
result
.
to_a
end
def
test_broken_yaml_exception
badyaml
=
Tempfile
.
new
[
"foo"
,
".yml"
]
badyaml
.
write
"a: : "
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录