Ticket #6569: assert_response_can_use_symbolic_status_codes.diff
| File assert_response_can_use_symbolic_status_codes.diff, 1.2 kB (added by kevinclark, 2 years ago) |
|---|
-
lib/action_controller/assertions/response_assertions.rb
old new 12 12 # * <tt>:error</tt>: Status code was in the 500-599 range 13 13 # 14 14 # You can also pass an explicit status code number as the type, like assert_response(501) 15 # Supports symbolic status codes 15 16 def assert_response(type, message = nil) 16 17 clean_backtrace do 17 18 if [ :success, :missing, :redirect, :error ].include?(type) && @response.send("#{type}?") 18 19 assert_block("") { true } # to count the assertion 19 20 elsif type.is_a?(Fixnum) && @response.response_code == type 20 21 assert_block("") { true } # to count the assertion 22 elsif type.is_a?(Symbol) && @response.response_code == ActionController::StatusCodes::SYMBOL_TO_STATUS_CODE[type] 23 assert_block("") { true } # to count the assertion 21 24 else 22 25 assert_block(build_message(message, "Expected response to be a <?>, but was <?>", type, @response.response_code)) { false } 23 26 end