Changeset 8245
- Timestamp:
- 11/30/07 21:04:57 (1 year ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/verification.rb (modified) (3 diffs)
- trunk/actionpack/test/controller/verification_test.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r8235 r8245 1 *SVN* 2 3 * Fixed that verification violations with no specified action didn't halt the chain (now they do with a 400 Bad Request) [DHH] 4 5 1 6 *2.0.0 [RC2]* (November 28th, 2007) 2 7 trunk/actionpack/lib/action_controller/verification.rb
r8106 r8245 13 13 # 14 14 # When a verification is violated, values may be inserted into the flash, and 15 # a specified redirection is triggered. 15 # a specified redirection is triggered. If no specific action is configured, 16 # verification failures will by default result in a 400 Bad Request response. 16 17 # 17 18 # Usage: … … 82 83 [*options[:params] ].find { |v| params[v].nil? } || 83 84 [*options[:session]].find { |v| session[v].nil? } || 84 [*options[:flash] ].find { |v| flash[v].nil? }85 [*options[:flash] ].find { |v| flash[v].nil? } 85 86 86 87 if !prereqs_invalid && options[:method] … … 94 95 flash.update(options[:add_flash]) if options[:add_flash] 95 96 response.headers.update(options[:add_headers]) if options[:add_headers] 97 96 98 unless performed? 97 render(options[:render]) if options[:render] 98 options[:redirect_to] = self.send!(options[:redirect_to]) if options[:redirect_to].is_a? Symbol 99 redirect_to(options[:redirect_to]) if options[:redirect_to] 99 case 100 when options[:render] 101 render(options[:render]) 102 when options[:redirect_to] 103 options[:redirect_to] = self.send!(options[:redirect_to]) if options[:redirect_to].is_a?(Symbol) 104 redirect_to(options[:redirect_to]) 105 else 106 head(:bad_request) 107 end 100 108 end 101 109 end 102 110 end 111 103 112 private :verify_action 104 113 end trunk/actionpack/test/controller/verification_test.rb
r6422 r8245 38 38 :redirect_to => :foo_url 39 39 40 verify :only => :no_default_action, :params => "santa" 41 40 42 def guarded_one 41 43 render :text => "#{params[:one]}" … … 88 90 def must_be_post 89 91 render :text => "Was a post!" 92 end 93 94 def no_default_action 95 # Will never run 90 96 end 91 97 … … 230 236 end 231 237 238 def test_default_failure_should_be_a_bad_request 239 post :no_default_action 240 assert_response :bad_request 241 end 242 232 243 def test_guarded_post_and_calls_render_fails_and_sets_allow_header 233 244 get :must_be_post