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

Fixed UrlHelper#link_to_unless so it doesn't care if the id is a string or fixnum [zenspider]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@256 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2004-12-22 22:50:44 +00:00
parent a89e36a22a
commit d91405a415
4 changed files with 11 additions and 5 deletions

View file

@ -1,5 +1,7 @@
*SVN*
* Fixed UrlHelper#link_to_unless so it doesn't care if the id is a string or fixnum [zenspider]
* Added search through session to clear out association caches at the end of each request. This makes it possible to place Active Record objects
in the session without worrying about stale data in the associations (the main object is still subject to caching, naturally) #347 [Tobias Luetke]

View file

@ -1,4 +1,5 @@
require 'cgi'
require 'erb'
module ActionView
module Helpers

View file

@ -96,9 +96,9 @@ module ActionView
def destination_equal_to_current(options)
params_without_location = @params.reject { |key, value| %w( controller action id ).include?(key) }
options[:action] == @params['action'] &&
options[:id] == @params['id'] &&
options[:controller] == @params['controller'] &&
options[:action].to_s == @params['action'].to_s &&
options[:id].to_s == @params['id'].to_s &&
options[:controller].to_s == @params['controller'].to_s &&
(options.has_key?(:params) ? params_without_location == options[:params] : true)
end
@ -120,4 +120,4 @@ module ActionView
end
end
end
end
end

View file

@ -43,6 +43,9 @@ class UrlHelperTest < Test::Unit::TestCase
@params = { "controller" => "weblog", "action" => "show"}
assert_equal "Showing", link_to_unless_current("Showing", :action => "show", :controller => "weblog")
assert "<a href=\"http://www.world.com\">Listing</a>", link_to_unless_current("Listing", :action => "list", :controller => "weblog")
@params = { "controller" => "weblog", "action" => "show", "id" => "1"}
assert_equal "Showing", link_to_unless_current("Showing", :action => "show", :controller => "weblog", :id => 1)
end
def test_mail_to
@ -58,4 +61,4 @@ class UrlHelperTest < Test::Unit::TestCase
assert "<a href=\"http://www.world.com\">Hello</a>",
link_to("Hello", {:action => 'myaction'}, nil)
end
end
end