Skip to content

Commit

Permalink
Support passing in arrays of raw cookies in addition to a newline sep…
Browse files Browse the repository at this point in the history
…arated string
  • Loading branch information
brynary committed Jun 19, 2009
1 parent 104997e commit 7159911
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions History.txt
Expand Up @@ -2,6 +2,8 @@

* Minor enhancements

* Support passing in arrays of raw cookies in addition to a newline
separated string
* Support after_request callbacks in MockSession for things like running
background jobs
* Allow multiple named sessions
Expand Down
2 changes: 1 addition & 1 deletion lib/rack/test/cookie_jar.rb
Expand Up @@ -116,7 +116,7 @@ def []=(name, value)
def merge(raw_cookies, uri = nil)
return unless raw_cookies

raw_cookies.each_line do |raw_cookie|
Array(raw_cookies).join("\n").split("\n").each do |raw_cookie|
cookie = Cookie.new(raw_cookie, uri, @default_host)
self << cookie if cookie.valid?(uri)
end
Expand Down
6 changes: 6 additions & 0 deletions spec/rack/test/cookie_spec.rb
Expand Up @@ -138,6 +138,12 @@ def have_body(string)
last_request.cookies.should == { "value" => "10" }
end

it "allows an array of cookies to be set" do
set_cookie ["value=10", "foo=bar"]
get "/cookies/show"
last_request.cookies.should == { "value" => "10", "foo" => "bar" }
end

it "accepts explicitly provided cookies" do
request "/cookies/show", :cookie => "value=1"
last_request.cookies.should == { "value" => "1" }
Expand Down

0 comments on commit 7159911

Please sign in to comment.