Changeset 4755
- Timestamp:
- 08/13/06 04:15:22 (2 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/base.rb (modified) (1 diff)
- trunk/actionpack/test/controller/base_test.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r4734 r4755 1 1 *SVN* 2 3 * Invoke method_missing directly on hidden actions. Closes #3030. [Nicholas Seckar] 2 4 3 5 * Require Tempfile explicitly for TestUploadedFile due to changes in class auto loading. [Rick Olson] trunk/actionpack/lib/action_controller/base.rb
r4728 r4755 975 975 end 976 976 end 977 977 978 978 def perform_action 979 if self.class.action_methods.include?(action_name) || self.class.action_methods.include?('method_missing')979 if self.class.action_methods.include?(action_name) 980 980 send(action_name) 981 render unless performed? 982 elsif respond_to? :method_missing 983 send(:method_missing, action_name) 981 984 render unless performed? 982 985 elsif template_exists? && template_public? trunk/actionpack/test/controller/base_test.rb
r4664 r4755 13 13 hide_action :hidden_action 14 14 def hidden_action 15 raise "Noooo!" 15 16 end 16 17 … … 32 33 def hidden_action 33 34 end 35 end 36 37 class MethodMissingController < ActionController::Base 38 39 hide_action :shouldnt_be_called 40 def shouldnt_be_called 41 raise "NO WAY!" 42 end 43 44 protected 45 46 def method_missing(selector) 47 render :text => selector.to_s 48 end 49 34 50 end 35 51 … … 65 81 end 66 82 end 83 67 84 end 85 86 87 class PerformActionTest < Test::Unit::TestCase 88 def use_controller(controller_class) 89 @controller = controller_class.new 90 91 # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get 92 # a more accurate simulation of what happens in "real life". 93 @controller.logger = Logger.new(nil) 94 95 @request = ActionController::TestRequest.new 96 @response = ActionController::TestResponse.new 97 98 @request.host = "www.nextangle.com" 99 end 100 101 def test_get_on_priv_should_show_selector 102 use_controller MethodMissingController 103 get :shouldnt_be_called 104 assert_response :success 105 assert_equal 'shouldnt_be_called', @response.body 106 end 107 108 def test_method_missing_is_not_an_action_name 109 use_controller MethodMissingController 110 assert ! @controller.send(:action_methods).include?('method_missing') 111 112 get :method_missing 113 assert_response :success 114 assert_equal 'method_missing', @response.body 115 end 116 117 def test_get_on_hidden_should_fail 118 use_controller NonEmptyController 119 get :hidden_action 120 assert_response 404 121 122 get :another_hidden_action 123 assert_response 404 124 end 125 end