1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fixed problem with cookies not being set to path=/ by default and a test buggerboo

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@110 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2004-12-10 17:16:11 +00:00
parent 0c72e6d665
commit 1188d3005a
2 changed files with 5 additions and 4 deletions

View file

@ -44,7 +44,7 @@ module ActionController #:nodoc:
options.each { |key, value| options[key.to_s] = value }
options["name"] = name.to_s
else
options = [ name, options ]
options = { "name" => name, "value" => options }
end
set_cookie(name, options)
@ -57,7 +57,8 @@ module ActionController #:nodoc:
private
def set_cookie(name, options) #:doc:
cookie = options.is_a?(Array) ? CGI::Cookie.new(*options) : CGI::Cookie.new(options)
options["path"] = "/" unless options["path"]
cookie = CGI::Cookie.new(options)
@controller.logger.info "Cookie set: #{cookie}" unless @controller.logger.nil?
@controller.response.headers["cookie"] << cookie
end

View file

@ -29,12 +29,12 @@ class UrlHelperTest < Test::Unit::TestCase
def test_link_to_image
assert_equal(
"<a href=\"http://www.world.com\"><img alt=\"Rss\" height=\"45\" src=\"/images/rss.png\" width=\"30\" /></a>",
"<a href=\"http://www.world.com\"><img alt=\"Rss\" border=\"0\" height=\"45\" src=\"/images/rss.png\" width=\"30\" /></a>",
link_to_image("rss", "http://www.world.com", "size" => "30x45")
)
assert_equal(
"<a class=\"admin\" href=\"http://www.world.com\"><img alt=\"Feed\" height=\"45\" src=\"/images/rss.gif\" width=\"30\" /></a>",
"<a class=\"admin\" href=\"http://www.world.com\"><img alt=\"Feed\" border=\"0\" height=\"45\" src=\"/images/rss.gif\" width=\"30\" /></a>",
link_to_image("rss.gif", "http://www.world.com", "size" => "30x45", "alt" => "Feed", "class" => "admin")
)
end