Permalink
Browse files

Merge pull request #72 from thibautsacreste/master

sinatra/cookies: cookies.delete did not pass the options to @response.delete_cookie
  • Loading branch information...
rkh committed Nov 9, 2012
2 parents cc6e212 + 0c131a8 commit 59cd6af54a5ef6619154e8d0f199d4688e657887
Showing with 22 additions and 6 deletions.
  1. +1 −1 lib/sinatra/cookies.rb
  2. +21 −5 spec/cookies_spec.rb
View
@@ -111,7 +111,7 @@ def default
def delete(key)
result = self[key]
- @response.delete_cookie(key.to_s)
+ @response.delete_cookie(key.to_s, @options)
result
end
View
@@ -154,11 +154,11 @@ def cookies(*set_cookies)
end.should be_nil
end
- it 'expiers existing cookies' do
+ it 'expires existing cookies' do
cookie_route("foo=bar") do
cookies.clear
response['Set-Cookie']
- end.should include("foo=; expires=Thu, 01-Jan-1970 00:00:00 GMT")
+ end.should include("foo=;", "expires=Thu, 01-Jan-1970 00:00:00 GMT")
end
end
@@ -185,16 +185,32 @@ def cookies(*set_cookies)
it 'removes response cookies from cookies hash' do
cookie_route do
cookies['foo'] = 'bar'
- cookies.clear
+ cookies.delete 'foo'
cookies['foo']
end.should be_nil
end
- it 'expiers existing cookies' do
+ it 'expires existing cookies' do
cookie_route("foo=bar") do
cookies.delete 'foo'
response['Set-Cookie']
- end.should include("foo=; expires=Thu, 01-Jan-1970 00:00:00 GMT")
+ end.should include("foo=;", "expires=Thu, 01-Jan-1970 00:00:00 GMT")
+ end
+
+ it 'honours the app cookie_options' do
+ @cookie_app.class_eval do
+ set :cookie_options, {
+ :path => '/foo',
+ :domain => 'bar.com',
+ :secure => true,
+ :httponly => true
+ }
+ end
+ cookie_header = cookie_route("foo=bar") do
+ cookies.delete 'foo'
+ response['Set-Cookie']
+ end
+ cookie_header.should include("path=/foo;", "domain=bar.com;", "secure;", "HttpOnly")
end
it 'does not touch other cookies' do

0 comments on commit 59cd6af

Please sign in to comment.