public this repo is viewable by everyone
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Fixed that formatted_polymorphic_route should be able to take the :format 
as part of a single hash or as the option hash (references #8741)
David Heinemeier Hansson (author)
about 1 month ago
commit  e89093aeb4b1f544cb54caf54a0374075250cc59
tree    cc4f9533e473c8453ce14e0a0340ef5e9dac0bd4
parent  f46fd6f2fceb22f00669f066fc98f92a18e5875f
...
73
74
75
76
 
77
78
79
...
152
153
154
 
 
 
 
 
 
 
 
 
 
155
156
157
...
73
74
75
 
76
77
78
79
...
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
0
@@ -73,7 +73,7 @@ module ActionController
0
       end
0
 
0
       record = extract_record(record_or_hash_or_array)
0
- format = (options[:action].to_s == "formatted" and record_or_hash_or_array.pop)
0
+ format = extract_format(record_or_hash_or_array, options)
0
       namespace = extract_namespace(record_or_hash_or_array)
0
       
0
       args = case record_or_hash_or_array
0
@@ -152,6 +152,16 @@ module ActionController
0
         end
0
       end
0
       
0
+ def extract_format(record_or_hash_or_array, options)
0
+ if options[:action].to_s == "formatted" && record_or_hash_or_array.is_a?(Array)
0
+ record_or_hash_or_array.pop
0
+ elsif options[:format]
0
+ options[:format]
0
+ else
0
+ nil
0
+ end
0
+ end
0
+
0
       def extract_namespace(record_or_hash_or_array)
0
         returning "" do |namespace|
0
           if record_or_hash_or_array.is_a?(Array)
...
65
66
67
68
69
 
70
71
 
72
73
74
 
 
 
 
 
 
75
76
77
...
65
66
67
 
 
68
69
 
70
71
72
73
74
75
76
77
78
79
80
81
82
0
@@ -65,13 +65,18 @@ uses_mocha 'polymorphic URL helpers' do
0
       formatted_polymorphic_url([@article, :pdf])
0
     end
0
 
0
- # TODO: should this work?
0
- def xtest_format_option
0
+ def test_format_option
0
       @article.save
0
- expects(:article_url).with(@article, :format => :pdf)
0
+ expects(:article_url).with(@article, :pdf)
0
       polymorphic_url(@article, :format => :pdf)
0
     end
0
 
0
+ def test_id_and_format_option
0
+ @article.save
0
+ expects(:article_url).with(:id => @article, :format => :pdf)
0
+ polymorphic_url(:id => @article, :format => :pdf)
0
+ end
0
+
0
     def test_with_nested
0
       @response.save
0
       expects(:article_response_url).with(@article, @response)

Comments

    No one has commented yet.