Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
81867540
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,发现更多精彩内容 >>
提交
81867540
编写于
5月 24, 2012
作者:
A
Andrew White
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6461 from schneems/schneems/sextant-routes
View your Routes without waiting on Rake
上级
abccf82c
c3e31029
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
104 addition
and
14 deletion
+104
-14
railties/CHANGELOG.md
railties/CHANGELOG.md
+2
-0
railties/lib/rails/application/finisher.rb
railties/lib/rails/application/finisher.rb
+2
-0
railties/lib/rails/application/route_inspector.rb
railties/lib/rails/application/route_inspector.rb
+1
-1
railties/lib/rails/info_controller.rb
railties/lib/rails/info_controller.rb
+25
-7
railties/lib/rails/templates/layouts/application.html.erb
railties/lib/rails/templates/layouts/application.html.erb
+32
-0
railties/lib/rails/templates/rails/info/properties.html.erb
railties/lib/rails/templates/rails/info/properties.html.erb
+1
-0
railties/lib/rails/templates/rails/info/routes.html.erb
railties/lib/rails/templates/rails/info/routes.html.erb
+9
-0
railties/test/application/route_inspect_test.rb
railties/test/application/route_inspect_test.rb
+9
-0
railties/test/application/routing_test.rb
railties/test/application/routing_test.rb
+12
-0
railties/test/rails_info_controller_test.rb
railties/test/rails_info_controller_test.rb
+11
-6
未找到文件。
railties/CHANGELOG.md
浏览文件 @
81867540
## Rails 4.0.0 (unreleased) ##
*
Add
`/rails/info/routes`
path, displays same information as
`rake routes`
*Richard Schneeman & Andrew White*
*
Improved
`rake routes`
output for redirects
*Łukasz Strzałkowski & Andrew White*
*
Load all environments available in
`config.paths["config/environments"]`
.
*Piotr Sarnacki*
...
...
railties/lib/rails/application/finisher.rb
浏览文件 @
81867540
...
...
@@ -23,6 +23,8 @@ module Finisher
if
Rails
.
env
.
development?
app
.
routes
.
append
do
get
'/rails/info/properties'
=>
"rails/info#properties"
get
'/rails/info/routes'
=>
"rails/info#routes"
get
'/rails/info'
=>
"rails/info#index"
end
end
end
...
...
railties/lib/rails/application/route_inspector.rb
浏览文件 @
81867540
...
...
@@ -51,7 +51,7 @@ def action
end
def
internal?
path
=~
%r{/rails/info
/properties
|^
#{
Rails
.
application
.
config
.
assets
.
prefix
}
}
path
=~
%r{/rails/info
.*
|^
#{
Rails
.
application
.
config
.
assets
.
prefix
}
}
end
def
engine?
...
...
railties/lib/rails/info_controller.rb
浏览文件 @
81867540
require
'rails/application/route_inspector'
class
Rails::InfoController
<
ActionController
::
Base
self
.
view_paths
=
File
.
join
(
File
.
dirname
(
__FILE__
),
'templates'
)
layout
'application'
before_filter
:require_local!
def
index
redirect_to
'/rails/info/routes'
end
def
properties
if
consider_all_requests_local?
||
request
.
local?
render
:inline
=>
Rails
::
Info
.
to_html
else
render
:text
=>
'<p>For security purposes, this information is only available to local requests.</p>'
,
:status
=>
:forbidden
end
@info
=
Rails
::
Info
.
to_html
end
def
routes
inspector
=
Rails
::
Application
::
RouteInspector
.
new
@info
=
inspector
.
format
(
_routes
.
routes
).
join
(
"
\n
"
)
end
protected
def
consider_all_requests_local?
Rails
.
application
.
config
.
consider_all_requests_local
def
require_local!
unless
local_request?
render
:text
=>
'<p>For security purposes, this information is only available to local requests.</p>'
,
:status
=>
:forbidden
end
end
def
local_request?
Rails
.
application
.
config
.
consider_all_requests_local
||
request
.
local?
end
end
railties/lib/rails/templates/layouts/application.html.erb
0 → 100644
浏览文件 @
81867540
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
/>
<title>
Routes
</title>
<style>
body
{
background-color
:
#fff
;
color
:
#333
;
}
body
,
p
,
ol
,
ul
,
td
{
font-family
:
helvetica
,
verdana
,
arial
,
sans-serif
;
font-size
:
13px
;
line-height
:
18px
;
}
pre
{
background-color
:
#eee
;
padding
:
10px
;
font-size
:
11px
;
white-space
:
pre-wrap
;
}
a
{
color
:
#000
;
}
a
:visited
{
color
:
#666
;
}
a
:hover
{
color
:
#fff
;
background-color
:
#000
;
}
</style>
</head>
<body>
<h2>
Your App:
<%=
link_to
'properties'
,
'/rails/info/properties'
%>
|
<%=
link_to
'routes'
,
'/rails/info/routes'
%>
</h2>
<%=
yield
%>
</body>
</html>
railties/lib/rails/templates/rails/info/properties.html.erb
0 → 100644
浏览文件 @
81867540
<%=
@info
.
html_safe
%>
\ No newline at end of file
railties/lib/rails/templates/rails/info/routes.html.erb
0 → 100644
浏览文件 @
81867540
<h2>
Routes
</h2>
<p>
Routes match in priority from top to bottom
</p>
<p><pre>
<%=
@info
%>
</pre></p>
\ No newline at end of file
railties/test/application/route_inspect_test.rb
浏览文件 @
81867540
...
...
@@ -164,5 +164,14 @@ def test_redirect
assert_equal
" bar GET /bar(.:format) redirect(307, path: /foo/bar)"
,
output
[
1
]
assert_equal
"foobar GET /foobar(.:format) redirect(301)"
,
output
[
2
]
end
def
test_presenter
output
=
draw
do
get
"/foo"
=>
redirect
(
"/foo/bar"
),
:constraints
=>
{
:subdomain
=>
"admin"
}
get
"/bar"
=>
redirect
(
path:
"/foo/bar"
,
status:
307
)
get
"/foobar"
=>
redirect
{
"/foo/bar"
}
end
assert_equal
output
.
join
(
"
\n
"
),
Rails
::
Application
::
RoutePresenter
.
display_routes
(
@set
.
routes
)
end
end
end
railties/test/application/routing_test.rb
浏览文件 @
81867540
...
...
@@ -15,12 +15,24 @@ def teardown
teardown_app
end
test
"rails/info/routes in development"
do
app
(
"development"
)
get
"/rails/info/routes"
assert_equal
200
,
last_response
.
status
end
test
"rails/info/properties in development"
do
app
(
"development"
)
get
"/rails/info/properties"
assert_equal
200
,
last_response
.
status
end
test
"rails/info/routes in production"
do
app
(
"production"
)
get
"/rails/info/routes"
assert_equal
404
,
last_response
.
status
end
test
"rails/info/properties in production"
do
app
(
"production"
)
get
"/rails/info/properties"
...
...
railties/test/rails_info_controller_test.rb
浏览文件 @
81867540
...
...
@@ -12,29 +12,28 @@ class InfoControllerTest < ActionController::TestCase
def
setup
Rails
.
application
.
routes
.
draw
do
get
'/rails/info/properties'
=>
"rails/info#properties"
get
'/rails/info/routes'
=>
"rails/info#routes"
end
@request
.
stubs
(
:local?
=>
true
)
@controller
.
stubs
(
:consider_all_requests_local?
=>
false
)
@controller
.
stubs
(
:local_request?
=>
true
)
@routes
=
Rails
.
application
.
routes
Rails
::
InfoController
.
send
(
:include
,
@routes
.
url_helpers
)
end
test
"info controller does not allow remote requests"
do
@
request
.
stubs
(
:local
?
=>
false
)
@
controller
.
stubs
(
:local_request
?
=>
false
)
get
:properties
assert_response
:forbidden
end
test
"info controller renders an error message when request was forbidden"
do
@
request
.
stubs
(
:local
?
=>
false
)
@
controller
.
stubs
(
:local_request
?
=>
false
)
get
:properties
assert_select
'p'
end
test
"info controller allows requests when all requests are considered local"
do
@request
.
stubs
(
:local?
=>
false
)
@controller
.
stubs
(
:consider_all_requests_local?
=>
true
)
@controller
.
stubs
(
:local_request?
=>
true
)
get
:properties
assert_response
:success
end
...
...
@@ -48,4 +47,10 @@ def setup
get
:properties
assert_select
'table'
end
test
"info controller renders with routes"
do
get
:routes
assert_select
'pre'
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录