aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/base_test.rb8
-rw-r--r--actionpack/test/controller/dispatcher_test.rb12
-rw-r--r--actionpack/test/controller/filters_test.rb2
-rw-r--r--actionpack/test/controller/integration_test.rb2
-rw-r--r--actionpack/test/controller/layout_test.rb16
-rw-r--r--actionpack/test/controller/mime_responds_test.rb36
-rw-r--r--actionpack/test/controller/mime_type_test.rb3
-rw-r--r--actionpack/test/controller/render_test.rb6
-rw-r--r--actionpack/test/controller/request_forgery_protection_test.rb2
9 files changed, 45 insertions, 42 deletions
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index bf1f6227fd..60e61b6285 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -75,11 +75,11 @@ class ControllerInstanceTests < Test::Unit::TestCase
def test_action_methods
@empty_controllers.each do |c|
hide_mocha_methods_from_controller(c)
- assert_equal Set.new, c.send(:action_methods), "#{c.controller_path} should be empty!"
+ assert_equal Set.new, c.send!(:action_methods), "#{c.controller_path} should be empty!"
end
@non_empty_controllers.each do |c|
hide_mocha_methods_from_controller(c)
- assert_equal Set.new('public_action'), c.send(:action_methods), "#{c.controller_path} should not be empty!"
+ assert_equal Set.new(%w(public_action)), c.send!(:action_methods), "#{c.controller_path} should not be empty!"
end
end
@@ -88,7 +88,7 @@ class ControllerInstanceTests < Test::Unit::TestCase
# considered actions, so explicitly hide_action them.
def hide_mocha_methods_from_controller(controller)
mocha_methods = [:expects, :metaclass, :mocha, :mocha_inspect, :reset_mocha, :stubba_object, :stubba_method, :stubs, :verify, :__metaclass__, :__is_a__]
- controller.class.send(:hide_action, *mocha_methods)
+ controller.class.send!(:hide_action, *mocha_methods)
end
end
@@ -116,7 +116,7 @@ class PerformActionTest < Test::Unit::TestCase
def test_method_missing_is_not_an_action_name
use_controller MethodMissingController
- assert ! @controller.send(:action_methods).include?('method_missing')
+ assert ! @controller.send!(:action_methods).include?('method_missing')
get :method_missing
assert_response :success
diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb
index f2bc091a72..75b99c4d92 100644
--- a/actionpack/test/controller/dispatcher_test.rb
+++ b/actionpack/test/controller/dispatcher_test.rb
@@ -52,12 +52,12 @@ class DispatcherTest < Test::Unit::TestCase
Dependencies.stubs(:load?).returns(false)
ActionController::Routing::Routes.expects(:reload).never
@dispatcher.unprepared = false
- @dispatcher.send(:reload_application)
+ @dispatcher.send!(:reload_application)
assert !@dispatcher.unprepared
Dependencies.stubs(:load?).returns(true)
ActionController::Routing::Routes.expects(:reload).once
- @dispatcher.send(:reload_application)
+ @dispatcher.send!(:reload_application)
assert @dispatcher.unprepared
end
@@ -69,19 +69,19 @@ class DispatcherTest < Test::Unit::TestCase
# Skip the callbacks when already prepared.
@dispatcher.unprepared = false
- @dispatcher.send :prepare_application
+ @dispatcher.send! :prepare_application
assert_nil a || b || c
# Perform the callbacks when unprepared.
@dispatcher.unprepared = true
- @dispatcher.send :prepare_application
+ @dispatcher.send! :prepare_application
assert_equal 1, a
assert_equal 2, b
assert_equal 3, c
# But when not :load, make sure they are only run once
a = b = c = nil
- @dispatcher.send :prepare_application
+ @dispatcher.send! :prepare_application
assert_nil a || b || c
end
@@ -91,7 +91,7 @@ class DispatcherTest < Test::Unit::TestCase
Dispatcher.to_prepare(:unique_id) { a = 2 }
@dispatcher.unprepared = true
- @dispatcher.send :prepare_application
+ @dispatcher.send! :prepare_application
assert_equal 2, a
assert_equal nil, b
end
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb
index 56aabddd31..0a081f5b92 100644
--- a/actionpack/test/controller/filters_test.rb
+++ b/actionpack/test/controller/filters_test.rb
@@ -332,7 +332,7 @@ class FilterTest < Test::Unit::TestCase
begin
yield
rescue ErrorToRescue => ex
- controller.send :render, :text => "I rescued this: #{ex.inspect}"
+ controller.send! :render, :text => "I rescued this: #{ex.inspect}"
end
end
end
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index d4b3862b2c..cf40d3462c 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -212,7 +212,7 @@ class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest
def test_integration_methods_called
%w( get post head put delete ).each do |verb|
- assert_nothing_raised("'#{verb}' should use integration test methods") { send(verb, '/') }
+ assert_nothing_raised("'#{verb}' should use integration test methods") { send!(verb, '/') }
end
end
diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb
index f194539fcf..85cc3a0843 100644
--- a/actionpack/test/controller/layout_test.rb
+++ b/actionpack/test/controller/layout_test.rb
@@ -93,16 +93,16 @@ class ExemptFromLayoutTest < Test::Unit::TestCase
end
def test_rjs_exempt_from_layout
- assert @controller.send(:template_exempt_from_layout?, 'test.rjs')
+ assert @controller.send!(:template_exempt_from_layout?, 'test.rjs')
end
def test_rhtml_and_rxml_not_exempt_from_layout
- assert !@controller.send(:template_exempt_from_layout?, 'test.rhtml')
- assert !@controller.send(:template_exempt_from_layout?, 'test.rxml')
+ assert !@controller.send!(:template_exempt_from_layout?, 'test.rhtml')
+ assert !@controller.send!(:template_exempt_from_layout?, 'test.rxml')
end
def test_other_extension_not_exempt_from_layout
- assert !@controller.send(:template_exempt_from_layout?, 'test.random')
+ assert !@controller.send!(:template_exempt_from_layout?, 'test.random')
end
def test_add_extension_to_exempt_from_layout
@@ -110,20 +110,20 @@ class ExemptFromLayoutTest < Test::Unit::TestCase
assert_nothing_raised do
ActionController::Base.exempt_from_layout ext
end
- assert @controller.send(:template_exempt_from_layout?, "test.#{ext}")
+ assert @controller.send!(:template_exempt_from_layout?, "test.#{ext}")
end
end
def test_add_regexp_to_exempt_from_layout
ActionController::Base.exempt_from_layout /\.rdoc/
- assert @controller.send(:template_exempt_from_layout?, 'test.rdoc')
+ assert @controller.send!(:template_exempt_from_layout?, 'test.rdoc')
end
def test_rhtml_exempt_from_layout_status_should_prevent_layout_render
ActionController::Base.exempt_from_layout :rhtml
- assert @controller.send(:template_exempt_from_layout?, 'test.rhtml')
- assert @controller.send(:template_exempt_from_layout?, 'hello.rhtml')
+ assert @controller.send!(:template_exempt_from_layout?, 'test.rhtml')
+ assert @controller.send!(:template_exempt_from_layout?, 'hello.rhtml')
get :hello
assert_equal 'hello.rhtml', @response.body
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
+
diff --git a/actionpack/test/controller/mime_type_test.rb b/actionpack/test/controller/mime_type_test.rb
index ed8f0357f4..d4aea3c01c 100644
--- a/actionpack/test/controller/mime_type_test.rb
+++ b/actionpack/test/controller/mime_type_test.rb
@@ -35,7 +35,8 @@ class MimeTypeTest < Test::Unit::TestCase
Mime::GIF
assert_equal Mime::GIF, Mime::SET.last
end
- Mime.send :remove_const, :GIF
+ ensure
+ Mime.module_eval { remove_const :GIF if const_defined?(:GIF) }
end
def test_type_convenience_methods
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 23c9613cad..22f7fcb790 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -157,9 +157,9 @@ class TestController < ActionController::Base
private
def determine_layout
case action_name
- when "layout_test": "layouts/standard"
- when "builder_layout_test": "layouts/builder"
- when "render_symbol_json": "layouts/standard" # to make sure layouts don't interfere
+ when "layout_test"; "layouts/standard"
+ when "builder_layout_test"; "layouts/builder"
+ when "render_symbol_json"; "layouts/standard" # to make sure layouts don't interfere
end
end
end
diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb
index 0990d1b0c5..616ff4f217 100644
--- a/actionpack/test/controller/request_forgery_protection_test.rb
+++ b/actionpack/test/controller/request_forgery_protection_test.rb
@@ -214,4 +214,4 @@ class FreeCookieControllerTest < Test::Unit::TestCase
assert_nothing_raised { send(method, :index)}
end
end
-end \ No newline at end of file
+end