aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/base_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller/base_test.rb')
-rw-r--r--actionpack/test/controller/base_test.rb39
1 files changed, 33 insertions, 6 deletions
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index f047e7da30..49f79681f6 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -56,6 +56,16 @@ protected
end
end
+class AnotherMethodMissingController < ActionController::Base
+ cattr_accessor :_exception
+ rescue_from Exception, :with => :_exception=
+
+ protected
+ def method_missing(*attrs, &block)
+ super
+ end
+end
+
class DefaultUrlOptionsController < ActionController::Base
def from_view
render :inline => "<%= #{params[:route]} %>"
@@ -124,11 +134,11 @@ class ControllerInstanceTests < Test::Unit::TestCase
def test_action_methods
@empty_controllers.each do |c|
- assert_equal Set.new, c.class.__send__(:action_methods), "#{c.controller_path} should be empty!"
+ assert_equal Set.new, c.class.action_methods, "#{c.controller_path} should be empty!"
end
@non_empty_controllers.each do |c|
- assert_equal Set.new(%w(public_action)), c.class.__send__(:action_methods), "#{c.controller_path} should not be empty!"
+ assert_equal Set.new(%w(public_action)), c.class.action_methods, "#{c.controller_path} should not be empty!"
end
end
@@ -173,6 +183,12 @@ class PerformActionTest < ActionController::TestCase
assert_equal 'method_missing', @response.body
end
+ def test_method_missing_should_recieve_symbol
+ use_controller AnotherMethodMissingController
+ get :some_action
+ assert_kind_of NameError, @controller._exception
+ end
+
def test_get_on_hidden_should_fail
use_controller NonEmptyController
assert_raise(ActionController::UnknownAction) { get :hidden_action }
@@ -191,7 +207,7 @@ class UrlOptionsTest < ActionController::TestCase
def test_url_options_override
with_routing do |set|
- set.draw do |map|
+ set.draw do
match 'from_view', :to => 'url_options#from_view', :as => :from_view
match ':controller/:action'
end
@@ -202,7 +218,18 @@ class UrlOptionsTest < ActionController::TestCase
assert_equal 'http://www.override.com/from_view?locale=en', @controller.send(:from_view_url)
assert_equal 'http://www.override.com/default_url_options/new?locale=en', @controller.url_for(:controller => 'default_url_options')
end
- end
+ end
+
+ def test_url_helpers_does_not_become_actions
+ with_routing do |set|
+ set.draw do
+ match "account/overview"
+ end
+
+ @controller.class.send(:include, set.url_helpers)
+ assert !@controller.class.action_methods.include?("account_overview_path")
+ end
+ end
end
class DefaultUrlOptionsTest < ActionController::TestCase
@@ -216,7 +243,7 @@ class DefaultUrlOptionsTest < ActionController::TestCase
def test_default_url_options_override
with_routing do |set|
- set.draw do |map|
+ set.draw do
match 'from_view', :to => 'default_url_options#from_view', :as => :from_view
match ':controller/:action'
end
@@ -231,7 +258,7 @@ class DefaultUrlOptionsTest < ActionController::TestCase
def test_default_url_options_are_used_in_non_positional_parameters
with_routing do |set|
- set.draw do |map|
+ set.draw do
scope("/:locale") do
resources :descriptions
end