Changeset 3838
- Timestamp:
- 03/11/06 01:23:29 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_controller/base.rb (modified) (3 diffs)
- trunk/actionpack/lib/action_controller/mime_responds.rb (added)
- trunk/actionpack/lib/action_controller/mime_type.rb (added)
- trunk/actionpack/lib/action_controller/request.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/test_process.rb (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/javascripts/prototype.js (modified) (1 diff)
- trunk/actionpack/test/controller/mime_responds_test.rb (added)
- trunk/actionpack/test/controller/new_render_test.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/webservice_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r3819 r3838 1 1 *SVN* 2 3 * Added better support for using the same actions to output for different sources depending on the Accept header [DHH]. Example: 4 5 class WeblogController < ActionController::Base 6 def create 7 @post = Post.create(params[:post]) 8 9 respond_to do |type| 10 type.js { render } # renders create.rjs 11 type.html { redirect_to :action => "index" } 12 type.xml do 13 headers["Location"] = url_for(:action => "show", :id => @post) 14 render(:nothing, :status => "201 Created") 15 end 16 end 17 end 18 end 19 20 * Added Base#render(:xml => xml) that works just like Base#render(:text => text), but sets the content-type to text/xml and the charset to UTF-8 [DHH] 2 21 3 22 * Integration test's url_for now runs in the context of the last request (if any) so after post /products/show/1 url_for :action => 'new' will yield /product/new [Tobias Luetke] trunk/actionpack/lib/action_controller.rb
r3777 r3838 45 45 require 'action_controller/layout' 46 46 require 'action_controller/dependencies' 47 require 'action_controller/mime_responds' 47 48 require 'action_controller/pagination' 48 49 require 'action_controller/scaffolding' … … 68 69 include ActionController::Rescue 69 70 include ActionController::Dependencies 71 include ActionController::MimeResponds 70 72 include ActionController::Pagination 71 73 include ActionController::Scaffolding trunk/actionpack/lib/action_controller/base.rb
r3806 r3838 1 require 'action_controller/mime_type' 1 2 require 'action_controller/request' 2 3 require 'action_controller/response' … … 649 650 elsif action_name = options[:action] 650 651 render_action(action_name, options[:status], options[:layout]) 651 652 653 elsif xml = options[:xml] 654 render_xml(xml, options[:status]) 655 652 656 elsif partial = options[:partial] 653 657 partial = default_template_name if partial == true … … 716 720 717 721 def render_javascript(javascript, status = nil) 718 @response.headers['Content-Type'] = 'text/javascript '722 @response.headers['Content-Type'] = 'text/javascript; charset=UTF-8' 719 723 render_text(javascript, status) 724 end 725 726 def render_xml(xml, status = nil) 727 @response.headers['Content-Type'] = 'text/xml; charset=UTF-8' 728 render_text(xml, status) 720 729 end 721 730 trunk/actionpack/lib/action_controller/request.rb
r3808 r3838 55 55 if @env['HTTP_X_POST_DATA_FORMAT'] 56 56 case @env['HTTP_X_POST_DATA_FORMAT'].downcase.to_sym 57 when :yaml 58 @content_type = 'application/x-yaml' 59 when :xml 60 @content_type = 'application/xml' 61 end 62 end 63 @content_type 57 when :yaml 58 @content_type = 'application/x-yaml' 59 when :xml 60 @content_type = 'application/xml' 61 end 62 end 63 64 @content_type = Mime::Type.new(@content_type) 65 end 66 67 def accepts 68 @accepts ||= (@env['HTTP_ACCEPT'].strip.blank? ? "*/*" : @env['HTTP_ACCEPT']).split(";").collect! do |mime_type| 69 Mime::Type.new(mime_type.strip) 70 end 64 71 end 65 72 trunk/actionpack/lib/action_controller/test_process.rb
r3820 r3838 105 105 self.query_parameters = {} 106 106 self.path_parameters = {} 107 @request_method =nil107 @request_method, @accepts, @content_type = nil, nil, nil 108 108 end 109 109 trunk/actionpack/lib/action_view/helpers/javascripts/prototype.js
r3795 r3838 704 704 var requestHeaders = 705 705 ['X-Requested-With', 'XMLHttpRequest', 706 'X-Prototype-Version', Prototype.Version]; 706 'X-Prototype-Version', Prototype.Version, 707 'Accept', 'text/javascript; text/html; text/xml; */*' ]; 707 708 708 709 if (this.options.method == 'post') { trunk/actionpack/test/controller/new_render_test.rb
r3814 r3838 545 545 get :update_page 546 546 assert_template nil 547 assert_equal 'text/javascript ', @response.headers['Content-Type']547 assert_equal 'text/javascript; charset=UTF-8', @response.headers['Content-Type'] 548 548 assert_equal 2, @response.body.split($/).length 549 549 end … … 552 552 get :update_page_with_instance_variables 553 553 assert_template nil 554 assert_equal 'text/javascript ', @response.headers['Content-Type']554 assert_equal 'text/javascript; charset=UTF-8', @response.headers['Content-Type'] 555 555 assert_match /balance/, @response.body 556 556 assert_match /\$37/, @response.body trunk/actionpack/test/controller/webservice_test.rb
r3778 r3838 72 72 73 73 def test_register_and_use_xml_simple 74 ActionController::Base.param_parsers['application/xml'] = :xml_simple74 ActionController::Base.param_parsers['application/xml'] = Proc.new { |data| XmlSimple.xml_in(data, 'ForceArray' => false) } 75 75 process('POST', 'application/xml', '<request><summary>content...</summary><title>SimpleXml</title></request>' ) 76 76 assert_equal 'summary, title', @controller.response.body