diff options
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/url_rewriter.rb | 7 | ||||
-rw-r--r-- | actionpack/test/controller/url_test.rb | 10 |
3 files changed, 16 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index b5aa3dd3d6..a2dd1aab98 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed url rewriter confusion when the controller name was a substring of the controller_prefix + * Added conditional layouts like <tt>layout "weblog_standard", :except => :rss</tt> #452 [Marcel Molina] * Fixed that MemCacheStore wasn't included by default and added default MemCache object pointing to localhost #447 [Lucas Carlson] diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb index cb6baf2c13..1ff172e8ad 100644 --- a/actionpack/lib/action_controller/url_rewriter.rb +++ b/actionpack/lib/action_controller/url_rewriter.rb @@ -88,10 +88,13 @@ module ActionController elsif action_prefix && !action_prefix.empty? path = path.sub(action_prefix, action_name(options, action_prefix)) else - path = path.sub(%r(#{@controller}/?), @controller + "/" + action_name(options)) # " ruby-mode + path = path.sub(%r(#{@controller}/?$), @controller + "/" + action_name(options)) # " ruby-mode end else - path = path.sub(@controller + "/" + (action_prefix || "") + @action + (action_suffix || ""), @controller + "/" + 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] diff --git a/actionpack/test/controller/url_test.rb b/actionpack/test/controller/url_test.rb index 21575f513a..93c8eb464d 100644 --- a/actionpack/test/controller/url_test.rb +++ b/actionpack/test/controller/url_test.rb @@ -191,7 +191,6 @@ class UrlTest < Test::Unit::TestCase 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 @@ -408,4 +407,13 @@ class UrlTest < Test::Unit::TestCase assert_equal("http://example.com/controller/foo", url.rewrite(:action => 'foo')) end + def test_rewriting_on_similar_fragments + url = ActionController::UrlRewriter.new( + MockRequest.new( + "http://", "example.com", 80, "/advertisements/advert/", + {"controller"=>"advert", "action"=>"index"} + ), "advert", "index" + ) + assert_equal("http://example.com/advertisements/advert/news", url.rewrite(:action => 'news')) + end end |