Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
fdd619e9
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,发现更多精彩内容 >>
提交
fdd619e9
编写于
9月 01, 2011
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CookieJar is enumerable. fixes #2795
上级
90248d29
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
0 deletion
+23
-0
actionpack/CHANGELOG
actionpack/CHANGELOG
+2
-0
actionpack/lib/action_dispatch/middleware/cookies.rb
actionpack/lib/action_dispatch/middleware/cookies.rb
+5
-0
actionpack/test/dispatch/cookies_test.rb
actionpack/test/dispatch/cookies_test.rb
+16
-0
未找到文件。
actionpack/CHANGELOG
浏览文件 @
fdd619e9
...
...
@@ -30,6 +30,8 @@
*
Rails
3.1.1
(
unreleased
)*
*
CookieJar
is
now
Enumerable
.
Fixes
#
2795
*
Fixed
AssetNotPrecompiled
error
raised
when
rake
assets
:
precompile
is
compiling
certain
.
erb
files
.
[
Guillermo
Iguaran
]
*
Manifest
is
correctly
placed
in
assets
path
when
default
assets
prefix
is
changed
.
[
Guillermo
Iguaran
]
...
...
actionpack/lib/action_dispatch/middleware/cookies.rb
浏览文件 @
fdd619e9
...
...
@@ -85,6 +85,7 @@ class Cookies
class
CookieOverflow
<
StandardError
;
end
class
CookieJar
#:nodoc:
include
Enumerable
# This regular expression is used to split the levels of a domain.
# The top level domain can be any string without a period or
...
...
@@ -124,6 +125,10 @@ def initialize(secret = nil, host = nil, secure = false)
alias
:closed?
:closed
def
close!
;
@closed
=
true
end
def
each
(
&
block
)
@cookies
.
each
(
&
block
)
end
# Returns the value of the cookie by +name+, or +nil+ if no such cookie exists.
def
[]
(
name
)
@cookies
[
name
.
to_s
]
...
...
actionpack/test/dispatch/cookies_test.rb
浏览文件 @
fdd619e9
...
...
@@ -148,6 +148,22 @@ def setup
@request
.
host
=
"www.nextangle.com"
end
def
test_each
request
.
cookie_jar
[
'foo'
]
=
:bar
list
=
[]
request
.
cookie_jar
.
each
do
|
k
,
v
|
list
<<
[
k
,
v
]
end
assert_equal
[[
'foo'
,
:bar
]],
list
end
def
test_enumerable
request
.
cookie_jar
[
'foo'
]
=
:bar
actual
=
request
.
cookie_jar
.
map
{
|
k
,
v
|
[
k
.
to_s
,
v
.
to_s
]
}
assert_equal
[[
'foo'
,
'bar'
]],
actual
end
def
test_key_methods
assert
!
request
.
cookie_jar
.
key?
(
:foo
)
assert
!
request
.
cookie_jar
.
has_key?
(
"foo"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录