Skip to content

Commit

Permalink
fixing default values used on unserialized cookie jars. closes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Feb 7, 2010
1 parent 1ef1355 commit a97e92b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Fixed a bug with iconv conversion. Thanks awesomeman! GH #9
* meta redirects outside the head are not followed. GH #13
* Form submissions work with nil page encodings. GH #25
* Fixing default values with serialized cookies. GH #3

=== 0.9.3

Expand Down
1 change: 1 addition & 0 deletions lib/mechanize/cookie_jar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def add(uri, cookie)
@jar[normal_domain] = Hash.new { |h,k| h[k] = {} }
end

@jar[normal_domain][cookie.path] ||= {}
@jar[normal_domain][cookie.path][cookie.name] = cookie
cleanup
cookie
Expand Down
11 changes: 11 additions & 0 deletions test/test_cookie_jar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,17 @@ def test_save_and_read_cookiestxt_with_session_cookies
FileUtils.rm("cookies.txt")
end

def test_save_and_read_expired_cookies
url = URI.parse('http://rubyforge.org/')

jar = Mechanize::CookieJar.new
jar.jar['rubyforge.org'] = {}

assert_nothing_raised do
jar.add(url, cookie_from_hash(cookie_values))
end
end

def test_ssl_cookies
# thanks to michal "ocher" ochman for reporting the bug responsible for this test.
values = cookie_values(:expires => nil)
Expand Down

0 comments on commit a97e92b

Please sign in to comment.