Changeset 6152
- Timestamp:
- 02/15/07 16:25:46 (2 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/mime_type.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/session_management.rb (modified) (1 diff)
- trunk/actionpack/test/controller/mime_type_test.rb (modified) (2 diffs)
- trunk/actionpack/test/template/form_tag_helper_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r6145 r6152 1 1 *SVN* 2 3 * Add Mime::Type convenience methods to check the current mime type. [Rick] 4 5 request.format.html? # => true if Mime::HTML 6 request.format.jpg? # => true if Mime::JPG 7 8 # ActionController sample usage: 9 # the session will be disabled for non html/ajax requests 10 session :off, :if => Proc.new { |req| !(req.format.html? || req.format.js?) } 2 11 3 12 * Performance: patch cgi/session to require digest/md5 once rather than per #create_new_id. [Stefan Kaes] trunk/actionpack/lib/action_controller/mime_type.rb
r6057 r6152 140 140 (@synonyms + [ self ]).any? { |synonym| synonym.to_s == mime_type.to_s } if mime_type 141 141 end 142 143 private 144 def method_missing(method, *args) 145 if method.to_s =~ /(\w+)\?$/ 146 mime_type = $1.downcase.to_sym 147 mime_type == @symbol || (mime_type == :html && @symbol == :all) 148 else 149 super 150 end 151 end 142 152 end 143 153 end trunk/actionpack/lib/action_controller/session_management.rb
r5838 r6152 61 61 # session :off, :only => :foo, 62 62 # :if => Proc.new { |req| req.parameters[:ws] } 63 # 64 # # the session will be disabled for non html/ajax requests 65 # session :off, 66 # :if => Proc.new { |req| !(req.format.html? || req.format.js?) } 63 67 # 64 68 # All session options described for ActionController::Base.process_cgi trunk/actionpack/test/controller/mime_type_test.rb
r4407 r6152 2 2 3 3 class MimeTypeTest < Test::Unit::TestCase 4 Mime:: PNG = Mime::Type.new("image/png")5 Mime:: PLAIN = Mime::Type.new("text/plain")4 Mime::Type.register "image/png", :png 5 Mime::Type.register "text/plain", :plain 6 6 7 7 def test_parse_single … … 31 31 Mime.send :remove_const, :GIF 32 32 end 33 34 def test_type_convenience_methods 35 types = [:html, :xml, :png, :plain, :yaml] 36 types.each do |type| 37 mime = Mime.const_get(type.to_s.upcase) 38 assert mime.send("#{type}?"), "Mime::#{type.to_s.upcase} is not #{type}?" 39 (types - [type]).each { |t| assert !mime.send("#{t}?"), "Mime::#{t.to_s.upcase} is #{t}?" } 40 end 41 end 42 43 def test_mime_all_is_html 44 assert Mime::ALL.all?, "Mime::ALL is not all?" 45 assert Mime::ALL.html?, "Mime::ALL is not html?" 46 end 33 47 end trunk/actionpack/test/template/form_tag_helper_test.rb
r6134 r6152 133 133 def test_submit_tag 134 134 assert_dom_equal( 135 %(<input name='commit' type='submit' value='Save' onclick="this.disabled=true;this.value='Saving...';alert('hello!');return (this.form.onsubmit ? this.form.onsubmit() : true)" />),135 %(<input name='commit' type='submit' value='Save' onclick="this.disabled=true;this.value='Saving...';alert('hello!');return (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit())" />), 136 136 submit_tag("Save", :disable_with => "Saving...", :onclick => "alert('hello!')") 137 137 )