Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
a6bf032b
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,体验更适合开发者的 AI 搜索 >>
提交
a6bf032b
编写于
4月 20, 2019
作者:
G
Gannon McGibbon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge pull request #35896 from jlw/bug/active-jobless-seeds
[#35782] Allow loading seeds without ActiveJob (~> 5.2.3)
上级
c617cc6b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
1 deletion
+37
-1
railties/CHANGELOG.md
railties/CHANGELOG.md
+6
-0
railties/lib/rails/engine.rb
railties/lib/rails/engine.rb
+1
-1
railties/test/railties/engine_test.rb
railties/test/railties/engine_test.rb
+30
-0
未找到文件。
railties/CHANGELOG.md
浏览文件 @
a6bf032b
*
Allow loading seeds without ActiveJob.
Fixes #35782
*Jeremy Weathers*
*
Only force
`:async`
ActiveJob adapter to
`:inline`
during seeding.
*BatedUrGonnaDie*
...
...
railties/lib/rails/engine.rb
浏览文件 @
a6bf032b
...
...
@@ -550,7 +550,7 @@ def load_seed
seed_file
=
paths
[
"db/seeds.rb"
].
existent
.
first
return
unless
seed_file
if
config
.
active_job
.
queue_adapter
==
:async
if
config
.
try
(
:active_job
)
&
.
queue_adapter
==
:async
with_inline_jobs
{
load
(
seed_file
)
}
else
load
(
seed_file
)
...
...
railties/test/railties/engine_test.rb
浏览文件 @
a6bf032b
...
...
@@ -905,6 +905,32 @@ def index
assert_instance_of
ActiveJob
::
QueueAdapters
::
DelayedJobAdapter
,
ActiveJob
::
Base
.
queue_adapter
end
test
"seed data can be loaded when ActiveJob is not present"
do
@plugin
.
write
"db/seeds.rb"
,
<<-
RUBY
Bukkits::Engine.config.bukkits_seeds_loaded = true
RUBY
app_file
"db/seeds.rb"
,
<<-
RUBY
Rails.application.config.app_seeds_loaded = true
RUBY
boot_rails
# In a real app, config.active_job would be undefined when
# NOT requiring rails/all AND NOT requiring active_job/railtie
# that doesn't work as expected in this test environment, so:
undefine_config_option
(
:active_job
)
assert_raise
(
NoMethodError
)
{
Rails
.
application
.
config
.
active_job
}
assert_raise
(
NoMethodError
)
{
Rails
.
application
.
config
.
app_seeds_loaded
}
assert_raise
(
NoMethodError
)
{
Bukkits
::
Engine
.
config
.
bukkits_seeds_loaded
}
Rails
.
application
.
load_seed
assert
Rails
.
application
.
config
.
app_seeds_loaded
Bukkits
::
Engine
.
load_seed
assert
Bukkits
::
Engine
.
config
.
bukkits_seeds_loaded
end
test
"skips nonexistent seed data"
do
FileUtils
.
rm
"
#{
app_path
}
/db/seeds.rb"
boot_rails
...
...
@@ -1523,5 +1549,9 @@ def index
def
app
Rails
.
application
end
def
undefine_config_option
(
name
)
Rails
.
application
.
config
.
class
.
class_variable_get
(
:@@options
).
delete
(
name
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录