Skip to content
Browse files

Fixed redirects when the controller and action is named the same. Sti…

…ll haven't fixed same controller, module, and action, though #201 [Josh]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@321 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 1f6c4ac commit 3e7a4ecc57da31c908982f933de65d33ebbfc344 @dhh dhh committed
View
2 actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed redirects when the controller and action is named the same. Still haven't fixed same controller, module, and action, though #201 [Josh]
+
* Fixed problems with running multiple functional tests in Rails under 1.8.2 by including hack for test/unit weirdness
* Added thread-safety to the DRbStore #66, #389 [Ben Stiglitz]
View
2 actionpack/lib/action_controller/url_rewriter.rb
@@ -91,7 +91,7 @@ def rewrite_action(path, options)
path = path.sub(%r(#{@controller}/?), @controller + "/" + action_name(options)) # " ruby-mode
end
else
- path = path.sub((action_prefix || "") + @action + (action_suffix || ""), action_name(options, action_prefix))
+ path = path.sub(@controller + "/" + (action_prefix || "") + @action + (action_suffix || ""), @controller + "/" + action_name(options, action_prefix))
end
if options[:controller_prefix] && !options[:controller]
View
17 actionpack/test/controller/url_test.rb
@@ -51,6 +51,14 @@ def setup
"http://", "www.singlefile.com", 80, "/identity/show/5", { "id" => "5" }
), "identity", "show")
+ @clean_url_with_same_action_and_controller_name = ActionController::UrlRewriter.new(MockRequest.new(
+ "http://", "www.singlefile.com", 80, "/login/login", { }
+ ), "login", "login")
+
+ @clean_url_with_same_action_and_controller_and_module_name = ActionController::UrlRewriter.new(MockRequest.new(
+ "http://", "www.singlefile.com", 80, "/login/login/login", { "module" => "login" }
+ ), "login", "login")
+
@clean_url_with_id_as_char = ActionController::UrlRewriter.new(MockRequest.new(
"http://", "www.singlefile.com", 80, "/teachers/show/t", { "id" => "t" }
), "teachers", "show")
@@ -179,6 +187,15 @@ def test_controller_and_index_action
assert_equal "http://www.singlefile.com/library/settings/", @library_url.rewrite(:controller => "settings", :action => "index")
end
+ def test_same_controller_and_action_names
+ assert_equal "http://www.singlefile.com/login/logout", @clean_url_with_same_action_and_controller_name.rewrite(:action => "logout")
+ end
+
+ # FIXME
+ def xtest_same_module_and_controller_and_action_names
+ assert_equal "http://www.singlefile.com/login/login/logout", @clean_url_with_same_action_and_controller_and_module_name.rewrite(:action => "logout")
+ end
+
def test_controller_and_action_with_same_name_as_controller
@clean_urls.each do |url|
assert_equal "http://www.singlefile.com/anything/identity", url.rewrite(:controller => "anything", :action => "identity")

0 comments on commit 3e7a4ec

Please sign in to comment.
Something went wrong with that request. Please try again.