mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
cookies.delete honours the app cookie options
This commit is contained in:
parent
5d0a23fdcd
commit
d83b594a3c
2 changed files with 22 additions and 6 deletions
|
@ -111,7 +111,7 @@ module Sinatra
|
|||
|
||||
def delete(key)
|
||||
result = self[key]
|
||||
@response.delete_cookie(key.to_s)
|
||||
@response.delete_cookie(key.to_s, @options)
|
||||
result
|
||||
end
|
||||
|
||||
|
|
|
@ -154,11 +154,11 @@ describe Sinatra::Cookies do
|
|||
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 @@ describe Sinatra::Cookies do
|
|||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue