aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-07-03 17:51:27 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2012-07-03 17:51:27 -0700
commit7ef6a27f89ee2cccc3a8f73123d2a7173c85f52f (patch)
tree8ce0afa24c5a036e698f715d413e8191f76c5bc4 /actionpack
parent142d50e52e5d33f061fa2909463c49e17dd4ddd1 (diff)
downloadrails-7ef6a27f89ee2cccc3a8f73123d2a7173c85f52f.tar.gz
rails-7ef6a27f89ee2cccc3a8f73123d2a7173c85f52f.tar.bz2
rails-7ef6a27f89ee2cccc3a8f73123d2a7173c85f52f.zip
add Mime.fetch so we can have default mime types
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/test_case.rb3
-rw-r--r--actionpack/lib/action_dispatch/http/mime_type.rb5
2 files changed, 6 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 1f5b8e46a2..398d2e6871 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -581,8 +581,7 @@ module ActionController
def html_format?(parameters)
return true unless parameters.is_a?(Hash)
- format = Mime[parameters[:format]]
- format.nil? || format.html?
+ Mime.fetch(parameters[:format]) { Mime['html'] }.html?
end
end
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb
index ee1913dbf9..83cd3d1ca8 100644
--- a/actionpack/lib/action_dispatch/http/mime_type.rb
+++ b/actionpack/lib/action_dispatch/http/mime_type.rb
@@ -29,6 +29,11 @@ module Mime
Type.lookup_by_extension(type.to_s)
end
+ def self.fetch(type)
+ return type if type.is_a?(Type)
+ EXTENSION_LOOKUP.fetch(type.to_s) { |k| yield k }
+ end
+
# Encapsulates the notion of a mime type. Can be used at render time, for example, with:
#
# class PostsController < ActionController::Base