Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
e91b4834
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 搜索 >>
提交
e91b4834
编写于
8月 15, 2017
作者:
R
Rafael França
提交者:
GitHub
8月 15, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #30257 from y-yagi/backport_29010
Backport #29010 to 5-1-stable
上级
c0a1dc25
b53a8469
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
6 deletion
+32
-6
railties/CHANGELOG.md
railties/CHANGELOG.md
+6
-0
railties/lib/rails/commands/console/console_command.rb
railties/lib/rails/commands/console/console_command.rb
+14
-2
railties/test/application/console_test.rb
railties/test/application/console_test.rb
+12
-4
未找到文件。
railties/CHANGELOG.md
浏览文件 @
e91b4834
*
Allow irb options to be passed from
`rails console`
command.
Fixes #28988.
*Yuji Yaginuma*
## Rails 5.1.3 (August 03, 2017) ##
*
No changes.
...
...
railties/lib/rails/commands/console/console_command.rb
浏览文件 @
e91b4834
...
...
@@ -73,14 +73,26 @@ class ConsoleCommand < Base # :nodoc:
class_option
:environment
,
aliases:
"-e"
,
type: :string
,
desc:
"Specifies the environment to run this console under (test/development/production)."
def
initialize
(
args
=
[],
local_options
=
{},
config
=
{})
console_options
=
[]
# For the same behavior as OptionParser, leave only options after "--" in ARGV.
termination
=
local_options
.
find_index
(
"--"
)
if
termination
console_options
=
local_options
[
termination
+
1
..-
1
]
local_options
=
local_options
[
0
...
termination
]
end
ARGV
.
replace
(
console_options
)
super
(
args
,
local_options
,
config
)
end
def
perform
extract_environment_option_from_argument
# RAILS_ENV needs to be set before config/application is required.
ENV
[
"RAILS_ENV"
]
=
options
[
:environment
]
ARGV
.
clear
# Clear ARGV so IRB doesn't freak.
require_application_and_environment!
Rails
::
Console
.
start
(
Rails
.
application
,
options
)
end
...
...
railties/test/application/console_test.rb
浏览文件 @
e91b4834
...
...
@@ -136,9 +136,9 @@ def write_prompt(command, expected_output = nil)
assert_output
"> "
end
def
spawn_console
def
spawn_console
(
options
)
Process
.
spawn
(
"
#{
app_path
}
/bin/rails console
--sandbox
"
,
"
#{
app_path
}
/bin/rails console
#{
options
}
"
,
in:
@slave
,
out:
@slave
,
err:
@slave
)
...
...
@@ -146,18 +146,26 @@ def spawn_console
end
def
test_sandbox
spawn_console
spawn_console
(
"--sandbox"
)
write_prompt
"Post.count"
,
"=> 0"
write_prompt
"Post.create"
write_prompt
"Post.count"
,
"=> 1"
@master
.
puts
"quit"
spawn_console
spawn_console
(
"--sandbox"
)
write_prompt
"Post.count"
,
"=> 0"
write_prompt
"Post.transaction { Post.create; raise }"
write_prompt
"Post.count"
,
"=> 0"
@master
.
puts
"quit"
end
def
test_environment_option_and_irb_option
spawn_console
(
"test -- --verbose"
)
write_prompt
"a = 1"
,
"a = 1"
write_prompt
"puts Rails.env"
,
"puts Rails.env
\r\n
test"
@master
.
puts
"quit"
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录