Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
a7695579
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 搜索 >>
提交
a7695579
编写于
12月 06, 2012
作者:
K
kennyj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ENV['RACK_ENV'] support to rake runner/console/server.
上级
396c0681
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
67 addition
and
5 deletion
+67
-5
railties/CHANGELOG.md
railties/CHANGELOG.md
+4
-0
railties/lib/rails/commands/console.rb
railties/lib/rails/commands/console.rb
+1
-1
railties/lib/rails/commands/runner.rb
railties/lib/rails/commands/runner.rb
+1
-1
railties/lib/rails/commands/server.rb
railties/lib/rails/commands/server.rb
+1
-1
railties/test/application/runner_test.rb
railties/test/application/runner_test.rb
+23
-0
railties/test/commands/console_test.rb
railties/test/commands/console_test.rb
+17
-2
railties/test/commands/server_test.rb
railties/test/commands/server_test.rb
+20
-0
未找到文件。
railties/CHANGELOG.md
浏览文件 @
a7695579
## Rails 4.0.0 (unreleased) ##
*
Add ENV['RACK_ENV'] support to
`rails runner/console/server`
.
*kennyj*
*
Add
`db`
to list of folders included by
`rake notes`
and
`rake notes:custom`
.
*Antonio Cangiano*
*
Engines with a dummy app include the rake tasks of dependencies in the app namespace.
...
...
railties/lib/rails/commands/console.rb
浏览文件 @
a7695579
...
...
@@ -45,7 +45,7 @@ def sandbox?
end
def
environment
options
[
:environment
]
||=
ENV
[
'RAILS_ENV'
]
||
'development'
options
[
:environment
]
||=
ENV
[
'RAILS_ENV'
]
||
ENV
[
'RACK_ENV'
]
||
'development'
end
def
environment?
...
...
railties/lib/rails/commands/runner.rb
浏览文件 @
a7695579
require
'optparse'
require
'rbconfig'
options
=
{
environment:
(
ENV
[
'RAILS_ENV'
]
||
"development"
).
dup
}
options
=
{
environment:
(
ENV
[
'RAILS_ENV'
]
||
ENV
[
'RACK_ENV'
]
||
"development"
).
dup
}
code_or_file
=
nil
if
ARGV
.
first
.
nil?
...
...
railties/lib/rails/commands/server.rb
浏览文件 @
a7695579
...
...
@@ -108,7 +108,7 @@ def default_options
super
.
merge
({
Port
:
3000
,
DoNotReverseLookup
:
true
,
environment:
(
ENV
[
'RAILS_ENV'
]
||
"development"
).
dup
,
environment:
(
ENV
[
'RAILS_ENV'
]
||
ENV
[
'RACK_ENV'
]
||
"development"
).
dup
,
daemonize:
false
,
debugger:
false
,
pid:
File
.
expand_path
(
"tmp/pids/server.pid"
),
...
...
railties/test/application/runner_test.rb
浏览文件 @
a7695579
...
...
@@ -67,5 +67,28 @@ def test_with_hook
assert_match
"true"
,
Dir
.
chdir
(
app_path
)
{
`bundle exec rails runner "puts Rails.application.config.ran"`
}
end
def
test_default_environment
assert_match
"development"
,
Dir
.
chdir
(
app_path
)
{
`bundle exec rails runner "puts Rails.env"`
}
end
def
test_environment_with_rails_env
orig
=
ENV
[
'RAILS_ENV'
]
ENV
[
'RAILS_ENV'
]
=
"production"
assert_match
"production"
,
Dir
.
chdir
(
app_path
)
{
`bundle exec rails runner "puts Rails.env"`
}
ensure
ENV
[
'RAILS_ENV'
]
=
orig
end
def
test_environment_with_rails_env
rack
,
rails
=
ENV
[
'RACK_ENV'
],
ENV
[
'RAILS_ENV'
]
ENV
[
'RACK_ENV'
]
=
"production"
ENV
[
'RAILS_ENV'
]
=
nil
assert_match
"production"
,
Dir
.
chdir
(
app_path
)
{
`bundle exec rails runner "puts Rails.env"`
}
ensure
ENV
[
'RAILS_ENV'
]
=
rails
ENV
[
'RACK_ENV'
]
=
rack
end
end
end
railties/test/commands/console_test.rb
浏览文件 @
a7695579
...
...
@@ -78,6 +78,13 @@ def test_default_environment_with_rails_env
assert_match
(
/\sspecial-production\s/
,
output
)
end
end
def
test_default_environment_with_rack_env
with_rack_env
'production'
do
start
assert_match
(
/\sproduction\s/
,
output
)
end
end
def
test_e_option
start
[
'-e'
,
'special-production'
]
...
...
@@ -128,10 +135,18 @@ def parse_arguments(args)
end
def
with_rails_env
(
env
)
original_rails_env
=
ENV
[
'RAILS_ENV'
]
rails
=
ENV
[
'RAILS_ENV'
]
ENV
[
'RAILS_ENV'
]
=
env
yield
ensure
ENV
[
'RAILS_ENV'
]
=
original_rails_env
ENV
[
'RAILS_ENV'
]
=
rails
end
def
with_rack_env
(
env
)
rack
=
ENV
[
'RACK_ENV'
]
ENV
[
'RACK_ENV'
]
=
env
with_rails_env
(
nil
)
{
yield
}
ensure
ENV
[
'RACK_ENV'
]
=
rack
end
end
railties/test/commands/server_test.rb
浏览文件 @
a7695579
...
...
@@ -23,4 +23,24 @@ def test_server_option_without_environment
assert_nil
options
[
:environment
]
assert_equal
'thin'
,
options
[
:server
]
end
def
test_environment_with_rails_env
rails
=
ENV
[
'RAILS_ENV'
]
ENV
[
'RAILS_ENV'
]
=
'production'
server
=
Rails
::
Server
.
new
assert_equal
'production'
,
server
.
options
[
:environment
]
ensure
ENV
[
'RAILS_ENV'
]
=
rails
end
def
test_environment_with_rack_env
rack
,
rails
=
ENV
[
'RACK_ENV'
],
ENV
[
'RAILS_ENV'
]
ENV
[
'RAILS_ENV'
]
=
nil
ENV
[
'RACK_ENV'
]
=
'production'
server
=
Rails
::
Server
.
new
assert_equal
'production'
,
server
.
options
[
:environment
]
ensure
ENV
[
'RACK_ENV'
]
=
rack
ENV
[
'RAILS_ENV'
]
=
rails
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录