Skip to content

Commit

Permalink
Remove method missing handling when action is not found, use action m…
Browse files Browse the repository at this point in the history
…issing instead

Do not create a method_missing method to handle not found actions, use
the action_missing method provided by Rails instead.
  • Loading branch information
carlosantoniodasilva committed Jan 17, 2012
1 parent 53596d0 commit a977b25
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 53 deletions.
8 changes: 0 additions & 8 deletions actionpack/lib/action_controller/metal/compatibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
45 changes: 0 additions & 45 deletions actionpack/test/controller/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]} %>"
Expand Down Expand Up @@ -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 }
Expand Down

0 comments on commit a977b25

Please sign in to comment.