aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/mime_responds_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-10-02 05:32:14 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-10-02 05:32:14 +0000
commit0ee1cb2cd32bfaf47deaf5440dd5b9cf0915ab6a (patch)
tree5778378eafcbdfa37c82c67be1566c76aca249be /actionpack/test/controller/mime_responds_test.rb
parent9264bdc8f618344307f07790a07a60dc04b80434 (diff)
downloadrails-0ee1cb2cd32bfaf47deaf5440dd5b9cf0915ab6a.tar.gz
rails-0ee1cb2cd32bfaf47deaf5440dd5b9cf0915ab6a.tar.bz2
rails-0ee1cb2cd32bfaf47deaf5440dd5b9cf0915ab6a.zip
Ruby 1.9 compat, consistent load paths
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7719 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/mime_responds_test.rb')
-rw-r--r--actionpack/test/controller/mime_responds_test.rb36
1 files changed, 19 insertions, 17 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index e0c0d1613a..4c48d4cdec 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -85,8 +85,8 @@ class RespondToController < ActionController::Base
type.html { render :text => "HTML" }
type.mobile { render :text => "Mobile" }
end
-
- Mime.send :remove_const, :MOBILE
+ ensure
+ Mime.module_eval { remove_const :MOBILE if const_defined?(:MOBILE) }
end
def custom_constant_handling_without_block
@@ -97,7 +97,8 @@ class RespondToController < ActionController::Base
type.mobile
end
- Mime.send :remove_const, :MOBILE
+ ensure
+ Mime.module_eval { remove_const :MOBILE if const_defined?(:MOBILE) }
end
def handle_any
@@ -123,7 +124,8 @@ class RespondToController < ActionController::Base
type.iphone { @type = "iPhone" }
end
- Mime.send :remove_const, :IPHONE
+ ensure
+ Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) }
end
def iphone_with_html_response_type_without_layout
@@ -135,7 +137,8 @@ class RespondToController < ActionController::Base
type.iphone { @type = "iPhone" ; render :action => "iphone_with_html_response_type" }
end
- Mime.send :remove_const, :IPHONE
+ ensure
+ Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) }
end
def rescue_action(e)
@@ -444,24 +447,23 @@ end
# For testing layouts which are set automatically
class PostController < AbstractPostController
around_filter :with_iphone
-
+
def index
respond_to do |type|
type.html
type.iphone
end
end
-
+
protected
-
- def with_iphone
- Mime::Type.register_alias("text/html", :iphone)
- request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone"
- yield
- Mime.send :remove_const, :IPHONE
- end
-
-end
+ def with_iphone
+ Mime::Type.register_alias("text/html", :iphone)
+ request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone"
+ yield
+ ensure
+ Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) }
+ end
+end
class SuperPostController < PostController
def index
@@ -501,4 +503,4 @@ class MimeControllerLayoutsTest < Test::Unit::TestCase
assert_equal '<html><div id="super_iphone">Super iPhone</div></html>', @response.body
end
end
- \ No newline at end of file
+