aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-06-08 16:14:38 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-06-08 16:15:14 -0700
commit38b608ecab2441cd0c4e75bc08bdf57fcf85dd71 (patch)
treeae901461df0ebe6b065b89a5db201d08fd5dda92 /actionpack/test
parenta470bb36128cfdddd888492b7ac972ee582f6acb (diff)
downloadrails-38b608ecab2441cd0c4e75bc08bdf57fcf85dd71.tar.gz
rails-38b608ecab2441cd0c4e75bc08bdf57fcf85dd71.tar.bz2
rails-38b608ecab2441cd0c4e75bc08bdf57fcf85dd71.zip
Writing comments to AbstractController
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract_controller/abstract_controller_test.rb24
-rw-r--r--actionpack/test/abstract_controller/callbacks_test.rb30
-rw-r--r--actionpack/test/abstract_controller/helper_test.rb2
-rw-r--r--actionpack/test/abstract_controller/layouts_test.rb30
4 files changed, 43 insertions, 43 deletions
diff --git a/actionpack/test/abstract_controller/abstract_controller_test.rb b/actionpack/test/abstract_controller/abstract_controller_test.rb
index 9c028e7d1e..c7eaaeb4ba 100644
--- a/actionpack/test/abstract_controller/abstract_controller_test.rb
+++ b/actionpack/test/abstract_controller/abstract_controller_test.rb
@@ -19,7 +19,7 @@ module AbstractController
class TestBasic < ActiveSupport::TestCase
test "dispatching works" do
- result = Me.process(:index)
+ result = Me.new.process(:index)
assert_equal "Hello world", result.response_body
end
end
@@ -68,27 +68,27 @@ module AbstractController
class TestRenderer < ActiveSupport::TestCase
test "rendering templates works" do
- result = Me2.process(:index)
+ result = Me2.new.process(:index)
assert_equal "Hello from index.erb", result.response_body
end
test "rendering passes ivars to the view" do
- result = Me2.process(:action_with_ivars)
+ result = Me2.new.process(:action_with_ivars)
assert_equal "Hello from index_with_ivars.erb", result.response_body
end
test "rendering with no template name" do
- result = Me2.process(:naked_render)
+ result = Me2.new.process(:naked_render)
assert_equal "Hello from naked_render.erb", result.response_body
end
test "rendering to a rack body" do
- result = Me2.process(:rendering_to_body)
+ result = Me2.new.process(:rendering_to_body)
assert_equal "Hello from naked_render.erb", result.response_body
end
test "rendering to a string" do
- result = Me2.process(:rendering_to_string)
+ result = Me2.new.process(:rendering_to_string)
assert_equal "Hello from naked_render.erb", result.response_body
end
end
@@ -120,12 +120,12 @@ module AbstractController
class TestPrefixedViews < ActiveSupport::TestCase
test "templates are located inside their 'prefix' folder" do
- result = Me3.process(:index)
+ result = Me3.new.process(:index)
assert_equal "Hello from me3/index.erb", result.response_body
end
test "templates included their format" do
- result = Me3.process(:formatted)
+ result = Me3.new.process(:formatted)
assert_equal "Hello from me3/formatted.html.erb", result.response_body
end
end
@@ -173,7 +173,7 @@ module AbstractController
class TestLayouts < ActiveSupport::TestCase
test "layouts are included" do
- result = Me4.process(:index)
+ result = Me4.new.process(:index)
assert_equal "Me4 Enter : Hello from me4/index.erb : Exit", result.response_body
end
end
@@ -210,7 +210,7 @@ module AbstractController
class TestRespondToAction < ActiveSupport::TestCase
def assert_dispatch(klass, body = "success", action = :index)
- response = klass.process(action).response_body
+ response = klass.new.process(action).response_body
assert_equal body, response
end
@@ -219,7 +219,7 @@ module AbstractController
end
test "raises ActionNotFound when method does not exist and action_missing is not defined" do
- assert_raise(ActionNotFound) { DefaultRespondToActionController.process(:fail) }
+ assert_raise(ActionNotFound) { DefaultRespondToActionController.new.process(:fail) }
end
test "dispatches to action_missing when method does not exist and action_missing is defined" do
@@ -231,7 +231,7 @@ module AbstractController
end
test "raises ActionNotFound if method is defined but respond_to_action? returns false" do
- assert_raise(ActionNotFound) { RespondToActionController.process(:fail) }
+ assert_raise(ActionNotFound) { RespondToActionController.new.process(:fail) }
end
end
diff --git a/actionpack/test/abstract_controller/callbacks_test.rb b/actionpack/test/abstract_controller/callbacks_test.rb
index 32450257f0..817f60f7d1 100644
--- a/actionpack/test/abstract_controller/callbacks_test.rb
+++ b/actionpack/test/abstract_controller/callbacks_test.rb
@@ -21,7 +21,7 @@ module AbstractController
class TestCallbacks < ActiveSupport::TestCase
test "basic callbacks work" do
- result = Callback1.process(:index)
+ result = Callback1.new.process(:index)
assert_equal "Hello world", result.response_body
end
end
@@ -52,17 +52,17 @@ module AbstractController
class TestCallbacks < ActiveSupport::TestCase
test "before_filter works" do
- result = Callback2.process(:index)
+ result = Callback2.new.process(:index)
assert_equal "Hello world", result.response_body
end
test "after_filter works" do
- result = Callback2.process(:index)
+ result = Callback2.new.process(:index)
assert_equal "Goodbye", result.instance_variable_get("@second")
end
test "around_filter works" do
- result = Callback2.process(:index)
+ result = Callback2.new.process(:index)
assert_equal "FIRSTSECOND", result.instance_variable_get("@aroundz")
end
end
@@ -83,12 +83,12 @@ module AbstractController
class TestCallbacks < ActiveSupport::TestCase
test "before_filter works with procs" do
- result = Callback3.process(:index)
+ result = Callback3.new.process(:index)
assert_equal "Hello world", result.response_body
end
test "after_filter works with procs" do
- result = Callback3.process(:index)
+ result = Callback3.new.process(:index)
assert_equal "Goodbye", result.instance_variable_get("@second")
end
end
@@ -118,17 +118,17 @@ module AbstractController
class TestCallbacks < ActiveSupport::TestCase
test "when :only is specified, a before filter is triggered on that action" do
- result = CallbacksWithConditions.process(:index)
+ result = CallbacksWithConditions.new.process(:index)
assert_equal "Hello, World", result.response_body
end
test "when :only is specified, a before filter is not triggered on other actions" do
- result = CallbacksWithConditions.process(:sekrit_data)
+ result = CallbacksWithConditions.new.process(:sekrit_data)
assert_equal "true", result.response_body
end
test "when :except is specified, an after filter is not triggered on that action" do
- result = CallbacksWithConditions.process(:index)
+ result = CallbacksWithConditions.new.process(:index)
assert_nil result.instance_variable_get("@authenticated")
end
end
@@ -158,17 +158,17 @@ module AbstractController
class TestCallbacks < ActiveSupport::TestCase
test "when :only is specified with an array, a before filter is triggered on that action" do
- result = CallbacksWithArrayConditions.process(:index)
+ result = CallbacksWithArrayConditions.new.process(:index)
assert_equal "Hello, World", result.response_body
end
test "when :only is specified with an array, a before filter is not triggered on other actions" do
- result = CallbacksWithArrayConditions.process(:sekrit_data)
+ result = CallbacksWithArrayConditions.new.process(:sekrit_data)
assert_equal "true", result.response_body
end
test "when :except is specified with an array, an after filter is not triggered on that action" do
- result = CallbacksWithArrayConditions.process(:index)
+ result = CallbacksWithArrayConditions.new.process(:index)
assert_nil result.instance_variable_get("@authenticated")
end
end
@@ -183,12 +183,12 @@ module AbstractController
class TestCallbacks < ActiveSupport::TestCase
test "when a callback is modified in a child with :only, it works for the :only action" do
- result = ChangedConditions.process(:index)
+ result = ChangedConditions.new.process(:index)
assert_equal "Hello world", result.response_body
end
test "when a callback is modified in a child with :only, it does not work for other actions" do
- result = ChangedConditions.process(:not_index)
+ result = ChangedConditions.new.process(:not_index)
assert_equal "", result.response_body
end
end
@@ -207,7 +207,7 @@ module AbstractController
class TestHalting < ActiveSupport::TestCase
test "when a callback sets the response body, the action should not be invoked" do
- result = SetsResponseBody.process(:index)
+ result = SetsResponseBody.new.process(:index)
assert_equal "Success", result.response_body
end
end
diff --git a/actionpack/test/abstract_controller/helper_test.rb b/actionpack/test/abstract_controller/helper_test.rb
index f91aefe606..0a2535f834 100644
--- a/actionpack/test/abstract_controller/helper_test.rb
+++ b/actionpack/test/abstract_controller/helper_test.rb
@@ -34,7 +34,7 @@ module AbstractController
class TestHelpers < ActiveSupport::TestCase
def test_helpers
- result = MyHelpers1.process(:index)
+ result = MyHelpers1.new.process(:index)
assert_equal "Hello World : Included", result.response_body
end
end
diff --git a/actionpack/test/abstract_controller/layouts_test.rb b/actionpack/test/abstract_controller/layouts_test.rb
index d3440c3de0..4b66f063f3 100644
--- a/actionpack/test/abstract_controller/layouts_test.rb
+++ b/actionpack/test/abstract_controller/layouts_test.rb
@@ -142,7 +142,7 @@ module AbstractControllerTests
end
# TODO Move to bootloader
- AbstractController::Base.subclasses.each do |klass|
+ AbstractController::Base.descendants.each do |klass|
klass = klass.constantize
next unless klass < AbstractController::Layouts
klass.class_eval do
@@ -152,70 +152,70 @@ module AbstractControllerTests
class TestBase < ActiveSupport::TestCase
test "when no layout is specified, and no default is available, render without a layout" do
- result = Blank.process(:index)
+ result = Blank.new.process(:index)
assert_equal "Hello blank!", result.response_body
end
test "when layout is specified as a string, render with that layout" do
- result = WithString.process(:index)
+ result = WithString.new.process(:index)
assert_equal "With String Hello string!", result.response_body
end
test "when layout is specified as a string, but the layout is missing, raise an exception" do
- assert_raises(ActionView::MissingTemplate) { WithMissingLayout.process(:index) }
+ assert_raises(ActionView::MissingTemplate) { WithMissingLayout.new.process(:index) }
end
test "when layout is specified as false, do not use a layout" do
- result = WithFalseLayout.process(:index)
+ result = WithFalseLayout.new.process(:index)
assert_equal "Hello false!", result.response_body
end
test "when layout is specified as nil, do not use a layout" do
- result = WithNilLayout.process(:index)
+ result = WithNilLayout.new.process(:index)
assert_equal "Hello nil!", result.response_body
end
test "when layout is specified as a symbol, call the requested method and use the layout returned" do
- result = WithSymbol.process(:index)
+ result = WithSymbol.new.process(:index)
assert_equal "OMGHI2U Hello symbol!", result.response_body
end
test "when layout is specified as a symbol and the method returns nil, don't use a layout" do
- result = WithSymbolReturningNil.process(:index)
+ result = WithSymbolReturningNil.new.process(:index)
assert_equal "Hello nilz!", result.response_body
end
test "when the layout is specified as a symbol and the method doesn't exist, raise an exception" do
- assert_raises(NoMethodError, /:nilz/) { WithSymbolAndNoMethod.process(:index) }
+ assert_raises(NoMethodError, /:nilz/) { WithSymbolAndNoMethod.new.process(:index) }
end
test "when the layout is specified as a symbol and the method returns something besides a string/false/nil, raise an exception" do
- assert_raises(ArgumentError) { WithSymbolReturningObj.process(:index) }
+ assert_raises(ArgumentError) { WithSymbolReturningObj.new.process(:index) }
end
test "when a child controller does not have a layout, use the parent controller layout" do
- result = WithStringChild.process(:index)
+ result = WithStringChild.new.process(:index)
assert_equal "With String Hello string!", result.response_body
end
test "when a child controller has specified a layout, use that layout and not the parent controller layout" do
- result = WithStringOverriddenChild.process(:index)
+ result = WithStringOverriddenChild.new.process(:index)
assert_equal "With Override Hello string!", result.response_body
end
test "when a child controller has an implied layout, use that layout and not the parent controller layout" do
- result = WithStringImpliedChild.process(:index)
+ result = WithStringImpliedChild.new.process(:index)
assert_equal "With Implied Hello string!", result.response_body
end
test "when a child controller specifies layout nil, do not use the parent layout" do
- result = WithNilChild.process(:index)
+ result = WithNilChild.new.process(:index)
assert_equal "Hello string!", result.response_body
end
test "when a grandchild has no layout specified, the child has an implied layout, and the " \
"parent has specified a layout, use the child controller layout" do
- result = WithChildOfImplied.process(:index)
+ result = WithChildOfImplied.new.process(:index)
assert_equal "With Implied Hello string!", result.response_body
end