gin 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +5 -0
- data/lib/gin.rb +1 -1
- data/lib/gin/controller.rb +17 -0
- data/test/test_controller.rb +10 -4
- metadata +3 -3
data/History.rdoc
CHANGED
data/lib/gin.rb
CHANGED
data/lib/gin/controller.rb
CHANGED
@@ -253,6 +253,23 @@ class Gin::Controller
|
|
253
253
|
end
|
254
254
|
|
255
255
|
|
256
|
+
##
|
257
|
+
# Set a cookie on the Rack response.
|
258
|
+
#
|
259
|
+
# set_cookie "mycookie", "FOO", :expires => 600, :path => "/"
|
260
|
+
# set_cookie "mycookie", :expires => 600
|
261
|
+
|
262
|
+
def set_cookie name, value=nil, opts={}
|
263
|
+
if Hash === value
|
264
|
+
opts = value
|
265
|
+
else
|
266
|
+
opts[:value] = value
|
267
|
+
end
|
268
|
+
|
269
|
+
@response.set_cookie name, opts
|
270
|
+
end
|
271
|
+
|
272
|
+
|
256
273
|
##
|
257
274
|
# Build a path to the given controller and action or route name,
|
258
275
|
# with any expected params. If no controller is specified and the
|
data/test/test_controller.rb
CHANGED
@@ -236,10 +236,16 @@ class ControllerTest < Test::Unit::TestCase
|
|
236
236
|
|
237
237
|
|
238
238
|
def test_set_cookie
|
239
|
-
|
240
|
-
@
|
241
|
-
|
242
|
-
|
239
|
+
exp = Time.now + 360
|
240
|
+
cookie = {:value => "user@example.com", :expires => exp}
|
241
|
+
|
242
|
+
@ctrl.set_cookie "test", "user@example.com", :expires => exp
|
243
|
+
expected = "test=user%40example.com; expires=#{exp.gmtime.strftime("%a, %d %b %Y %H:%M:%S -0000")}"
|
244
|
+
assert_equal expected, @ctrl.response['Set-Cookie']
|
245
|
+
|
246
|
+
@ctrl.set_cookie "test", :path => "/"
|
247
|
+
expected << "\ntest=; path=/"
|
248
|
+
assert_equal expected, @ctrl.response['Set-Cookie']
|
243
249
|
end
|
244
250
|
|
245
251
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -150,7 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
segments:
|
152
152
|
- 0
|
153
|
-
hash:
|
153
|
+
hash: -3176863341583704067
|
154
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
155
|
none: false
|
156
156
|
requirements:
|