提交 a977b258 编写于 作者: C Carlos Antonio da Silva

Remove method missing handling when action is not found, use action missing instead

Do not create a method_missing method to handle not found actions, use
the action_missing method provided by Rails instead.
上级 53596d09
......@@ -17,13 +17,5 @@ class << self
def render_to_body(options)
super || " "
end
def _handle_method_missing
method_missing(@_action_name.to_sym)
end
def method_for_action(action_name)
super || (respond_to?(:method_missing) && "_handle_method_missing")
end
end
end
......@@ -40,29 +40,6 @@ def hidden_action
end
end
class MethodMissingController < ActionController::Base
hide_action :shouldnt_be_called
def shouldnt_be_called
raise "NO WAY!"
end
protected
def method_missing(selector)
render :text => selector.to_s
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]} %>"
......@@ -159,28 +136,6 @@ def test_process_should_be_precise
assert_equal exception.message, "The action 'non_existent' could not be found for EmptyController"
end
def test_get_on_priv_should_show_selector
use_controller MethodMissingController
get :shouldnt_be_called
assert_response :success
assert_equal 'shouldnt_be_called', @response.body
end
def test_method_missing_is_not_an_action_name
use_controller MethodMissingController
assert !@controller.__send__(:action_method?, 'method_missing')
get :method_missing
assert_response :success
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(AbstractController::ActionNotFound) { get :hidden_action }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册