public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Fix url_for with no arguments when default_url_options is not explicitly 
defined. [#339 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Luke Redpath (author)
Thu Jun 05 05:20:54 -0700 2008
lifo (committer)
Tue Jun 17 12:53:41 -0700 2008
commit  7650ff892cbffcaaaf9c5ab72466e98903a202d3
tree    bc0a124be51c0fe7711e479aecfa24cf3e8c947c
parent  bc4a2f156b368334ca7267d15f4dd10864ac492d
...
606
607
608
609
610
 
 
611
612
613
...
606
607
608
 
 
609
610
611
612
613
0
@@ -606,8 +606,8 @@ module ActionController #:nodoc:
0
       #
0
       # This takes the current URL as is and only exchanges the action. In contrast, <tt>url_for :action => 'print'</tt>
0
       # would have slashed-off the path components after the changed action.
0
-      def url_for(options = nil) #:doc:
0
-        case options || {}
0
+      def url_for(options = {}) #:doc:
0
+        case options
0
           when String
0
             options
0
           when Hash
...
169
170
171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
173
174
...
180
181
182
183
184
 
...
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
...
196
197
198
 
199
200
0
@@ -169,6 +169,22 @@ class DefaultUrlOptionsTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
+class EmptyUrlOptionsTest < Test::Unit::TestCase
0
+  def setup
0
+    @controller = NonEmptyController.new
0
+
0
+    @request    = ActionController::TestRequest.new
0
+    @response   = ActionController::TestResponse.new
0
+
0
+    @request.host = 'www.example.com'
0
+  end
0
+
0
+  def test_ensure_url_for_works_as_expected_when_called_with_no_options_if_default_url_options_is_not_set
0
+    get :public_action
0
+    assert_equal "http://www.example.com/non_empty/public_action", @controller.url_for
0
+  end
0
+end
0
+
0
 class EnsureNamedRoutesWorksTicket22BugTest < Test::Unit::TestCase
0
   def test_named_routes_still_work
0
     ActionController::Routing::Routes.draw do |map|
0
@@ -180,4 +196,4 @@ class EnsureNamedRoutesWorksTicket22BugTest < Test::Unit::TestCase
0
   ensure
0
     ActionController::Routing::Routes.load!
0
   end
0
-end
0
\ No newline at end of file
0
+end

Comments