Changeset 4860
- Timestamp:
- 08/30/06 00:34:36 (2 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/base.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/mime_responds.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_controller/mime_type.rb (modified) (1 diff)
- trunk/actionpack/test/controller/mime_responds_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r4833 r4860 1 1 *SVN* 2 3 * respond_to .html now always renders #{action_name}.rhtml so that registered custom template handlers do not override it in priority. Custom mime types require a block and throw proper error now. [Tobias Luetke] 2 4 3 5 * Deprecation: test deprecated instance vars in partials. [Jeremy Kemper] trunk/actionpack/lib/action_controller/base.rb
r4755 r4860 27 27 end 28 28 class MissingFile < ActionControllerError #:nodoc: 29 end 30 class RenderError < ActionControllerError #:nodoc: 29 31 end 30 32 class SessionOverflowError < ActionControllerError #:nodoc: trunk/actionpack/lib/action_controller/mime_responds.rb
r4759 r4860 109 109 110 110 class Responder #:nodoc: 111 DEFAULT_BLOCKS = { 112 :html => 'Proc.new { render }', 113 :js => 'Proc.new { render :action => "#{action_name}.rjs" }', 114 :xml => 'Proc.new { render :action => "#{action_name}.rxml" }' 115 } 111 DEFAULT_BLOCKS = [:html, :js, :xml].inject({}) do |blocks, ext| 112 blocks.update ext => %(Proc.new { render :action => "\#{action_name}.r#{ext}" }) 113 end 116 114 117 115 def initialize(block_binding) … … 135 133 @responses[mime_type] = block 136 134 else 137 @responses[mime_type] = eval(DEFAULT_BLOCKS[mime_type.to_sym], @block_binding) 135 if source = DEFAULT_BLOCKS[mime_type.to_sym] 136 @responses[mime_type] = eval(source, @block_binding) 137 else 138 raise ActionController::RenderError, "Expected a block but none was given for custom mime handler #{mime_type}" 139 end 138 140 end 139 141 end trunk/actionpack/lib/action_controller/mime_type.rb
r4622 r4860 35 35 Mime.send :const_set, symbol.to_s.upcase, Type.new(string, symbol, synonyms) 36 36 SET << Mime.send(:const_get, symbol.to_s.upcase) 37 LOOKUP[string] = EXTENSION_LOOKUP[symbol.to_s] = SET.last 37 LOOKUP[string] = EXTENSION_LOOKUP[symbol.to_s] = SET.last 38 38 end 39 39 trunk/actionpack/test/controller/mime_responds_test.rb
r4409 r4860 73 73 Mime.send :remove_const, :MOBILE 74 74 end 75 76 def custom_constant_handling_without_block 77 Mime::Type.register("text/x-mobile", :mobile) 78 79 respond_to do |type| 80 type.html { render :text => "HTML" } 81 type.mobile 82 end 83 84 Mime.send :remove_const, :MOBILE 85 end 86 75 87 76 88 def handle_any … … 272 284 end 273 285 286 def custom_constant_handling_without_block 287 288 assert_raised(ActionController::RenderError) do 289 get :custom_constant_handling, :format => "mobile" 290 end 291 end 292 274 293 def test_forced_format 275 294 get :html_xml_or_rss