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>
lukeredpath (author)
Thu Jun 05 05:20:54 -0700 2008
lifo (committer)
Tue Jun 17 13:00:28 -0700 2008
commit  a83ac48501aaba12b3d8abc0c6d6fdf0155de74d
tree    4482edf993ac1d6c0e43dd79d2748563ae8c1ddd
parent  5c071a78bea7f1a1bdee4e75a730dfca25ee938c
...
613
614
615
616
617
 
 
618
619
620
...
613
614
615
 
 
616
617
618
619
620
0
@@ -613,8 +613,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

    No one has commented yet.