aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/debug_exceptions_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Change `ActionDispatch::Response#content_type` returning Content-Type header ↵yuuji.yaginuma2019-06-011-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | as it is Since #35709, `Response#conten_type` returns only MIME type correctly. It is a documented behavior that this method only returns MIME type, so this change seems appropriate. https://github.com/rails/rails/blob/39de7fac0507070e3c5f8b33fbad6fced84d97ed/actionpack/lib/action_dispatch/http/response.rb#L245-L249 But unfortunately, some users expect this method to return all Content-Type that does not contain charset. This seems to be breaking changes. We can change this behavior with the deprecate cycle. But, in that case, a method needs that include Content-Type with additional parameters. And that method name is probably the `content_type` seems to properly. So I changed the new behavior to more appropriate `media_type` method. And `Response#content_type` changed (as the method name) to return Content-Type header as it is. Fixes #35709. [Rafael Mendonça França & Yuuji Yaginuma ]
* Merge pull request #36196 from st0012/fix-29947Eileen M. Uchitelle2019-05-071-0/+19
| | | | | | | Hide malformed parameters from error page Accidentally merged this to 6-0-stable so forward porting it to master here instead.
* Drop the ambiguous `ActiveSupport::ActionableError#===` checkGenadi Samokovarov2019-04-191-0/+31
|
* url -> URL where apt inside actionpack/Sharang Dashputre2019-04-011-1/+1
|
* Add the `Mime::Type::InvalidMimeType` error in the default rescue_response:Edouard CHIN2019-03-261-0/+6
| | | | | | | | | | | | | | | - https://github.com/rails/rails/pull/35604 introduced a vulnerability fix to raise an error in case the `HTTP_ACCEPT` headers contains malformated mime type. This will cause applications to throw a 500 if a User Agent sends an invalid header. This PR adds the `InvalidMimeType` in the default `rescue_responses` from the ExceptionWrapper and will return a 406. I looked up the HTTP/1.1 RFC and it doesn't stand what should be returned when the UA sends malformated mime type. Decided to get 406 as it seemed to be the status the better suited for this.
* Pass locals in to the template object on constructionAaron Patterson2019-02-251-1/+1
| | | | | | | This commit ensures that locals are passed in to the template objects when they are constructed, then removes the `locals=` mutator on the template object. This means we don't need to mutate Template objects with locals in the `decorate` method.
* Always pass a format to the ActionView::Template constructorAaron Patterson2019-02-251-1/+1
| | | | | This means we can eliminate nil checks and remove some mutations from the `decorate` method.
* Loosen check of error cause fileyuuji.yaginuma2019-01-261-2/+2
| | | | | Since "actionpack" is not included in isolation test. Ref: https://travis-ci.org/rails/rails/jobs/484514392#L2715
* Fixed a bug where the debug view does not show the error page properlyYuki Nishijima2019-01-241-2/+19
| | | | | | | | | | | | | | | | | | | | | There are two cases where the debug view does not show the error details properly: * When the cause is mapped to an HTTP status code the last exception is unexpectedly uwrapped * When the last error is thrown from a view template the debug view is not using the `rescues/template_error.html.erb` to generate the view Both the cases could be fixed by not unwrapping the exception. The only case where the exception should be unwrapped is when the last error is an `ActionView::Template::Error` object. In this case the HTTP status code is determined based on the cause. There are actually more wrapper exceptions that are intentionally thrown. However, there is a consistent pattern of setting the original message and original backtrace to the wrapper exception implemented, so the debug view will not lose the information about what went wrong eariler.
* Prefer strings over regex expressionsYuki Nishijima2019-01-241-22/+20
| | | | | | | | | | | | | | | | | | In this case statement, there are two patterns that start with the same line: when %r{/not_found} ... when %r{/not_found_original_exception} ... Because the string "/not_found_original_exception" does match the first one, it is never routed to what it is supposed to be routed, causing one of the tests for DebugExceptions to happen to be passing. After changing the regex expressions back to strings, I noticed that the test setup is not complete (the template object needs to be a proper template object). Once I fixed it all the tests started padding.
* 1. Replaced unused variables by `_`.alkesh262019-01-221-1/+1
| | | | 2. Typo fixes.
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-211-18/+14
| | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* Show nested exceptions on the debug viewYuki Nishijima2018-07-151-11/+60
|
* Introduce ActionDispatch::DebugExceptions interceptorsGenadi Samokovarov2018-04-201-0/+24
| | | | | | | | | | | | | | Plugins interacting with the exceptions caught and displayed by ActionDispatch::DebugExceptions currently have to monkey patch it to get the much needed exception for their calculation. With DebugExceptions.register_interceptor, plugin authors can hook into DebugExceptions and process the exception, before being rendered. They can store it into the request and process it on the way back of the middleware chain execution or act on it straight in the interceptor. The interceptors can be play blocks, procs, lambdas or any object that responds to `#call`.
* [Action Pack] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Prepare AP and AR to be frozen string friendlyKir Shatrov2017-07-061-1/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* Support plain loggers in DebugExceptionsGenadi Samokovarov2016-10-281-0/+17
| | | | | | | | | | | | | | I have been seeing people setting `Logger` instances for `config.logger` and it blowing up on `rails/web-console` usage. Now, I doubt many folks are manually setting `ActionView::Base.logger`, but given that `DebugExceptions` is running in a pretty fragile environment already, having it crash (and being silent) in those cases can be pretty tricky to trace down. I'm proposing we verify whether the `ActionView::Base.logger` supports silencing before we try to do it, to save us the headache of tracing it down.
* Add three new rubocop rulesRafael Mendonça França2016-08-161-3/+3
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+0
|
* applies new string literal convention in actionpack/testXavier Noria2016-08-061-98/+98
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Ensure logging on exceptions only includes what we expectMatthew Draper2016-07-021-0/+23
|
* Merge pull request #24912 from prathamesh-sonpatki/api-fix-response-formatSantiago Pastorino2016-05-111-32/+50
|\ | | | | API only apps: Preserve request format for HTML requests too
| * API only apps: Preserve request format for HTML requests tooPrathamesh Sonpatki2016-05-111-32/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | - Earlier we were responding with JSON format for HTML requests in a API app. - Now we will respond with HTML format for such requests in API apps. - Also earlier we were not testing the API app's JSON requests properly. We were actually sending HTML requests. Now we send correct JSON requests. Also added more test coverage. - Based on the discussion from this commit - https://github.com/rails/rails/commit/05d89410bf97d0778e78558db3c9fed275f8a614. [Prathamesh Sonpatki, Jorge Bejar]
* | BoomerAPI is not used anywhere, so removed it!Prathamesh Sonpatki2016-05-061-7/+0
|/ | | | | - It was originally added in 83b4e9073f0852afc065 and partially removed in 05d89410bf97d0778e7.
* DebugException initialize with a response_format valueJorge Bejar2015-12-091-2/+2
|
* Fix some edge cases in AD::DebugExceptions in rails api appsJorge Bejar2015-12-091-11/+62
|
* Response when error should be formatted properly in Rails API if local requestJorge Bejar2015-12-091-0/+18
|
* Merge pull request #22172 from tijmenb/fix-source-in-show-exceptionRafael França2015-11-241-0/+8
|\ | | | | Add text template for source code
| * Add text template for source codeTijmen Brommet2015-11-031-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a request is made with AJAX and an error occurs, Rails will render a text-template for the exception instead of the HTML error page (#11960). The `.text.erb` variant of the `_source` template is currently missing, causing HTML to be rendered in the response. This commit adds the text template. To keep the page scannable we only only show the first three source extracts. Related to #14745. Before: ``` ~/testing-exceptions ᐅ curl 'http://localhost:3000/' -H 'X-Requested-With: XMLHttpRequest' RuntimeError in PostsController#index <div class="source " id="frame-source-0"> <div class="info"> Extracted source (around line <strong>#3</strong>): </div> <div class="data"> <table cellpadding="0" cellspacing="0" class="lines"> <tr> ``` After: ``` ~/testing-exceptions ᐅ curl 'http://localhost:3000/' -H 'X-Requested-With: XMLHttpRequest' RuntimeError in PostsController#index Extracted source (around line #3): *3 raise ```
* | Fix typo [ci skip]Jake Worth2015-11-121-1/+1
|/
* Deprecate exception#original_exception in favor of exception#causeYuki Nishijima2015-11-031-3/+7
|
* Remove mocha from ActionPack testsMarcin Olichwirowicz2015-09-051-3/+6
|
* Get rid of mocha tests - part 2Marcin Olichwirowicz2015-08-251-32/+25
|
* Avoid accurate assertions on error messagesRobin Dupret2015-03-021-2/+2
| | | | | Since there are disparities between the raised error messages on the different implementations, let's avoid being too accurate.
* Consistent usage of spaces in hashes across our codebaseRafael Mendonça França2015-01-291-22/+22
|
* Switch to kwargs in ActionController::TestCase and ActionDispatch::IntegrationKir Shatrov2015-01-291-31/+31
| | | | | | | | Non-kwargs requests are deprecated now. Guides are updated as well. `post url, nil, nil, { a: 'b' }` doesn't make sense. `post url, params: { y: x }, session: { a: 'b' }` would be an explicit way to do the same
* Refactor debug viewKir Shatrov2014-12-021-0/+23
| | | Avoid logic in ERB and use helpers
* Show source view and backtrace on missing template errorsGenadi Samokovarov2014-11-241-0/+27
| | | | | | | | | This will help you debug missing template errors, especially if they come from a programmatic template selection. Thanks to @dhh for suggesting that. As a bonus, also show request and response info on the routing error page for consistency.
* Show the user’s application in the source window and select the correct ↵Byron Bischoff2014-10-231-1/+41
| | | | trace list, closes #17312
* Expectations firstAkira Matsuda2014-08-181-6/+6
|
* Merge pull request #16303 from rajcybage/removing_masterYves Senn2014-07-281-0/+2
|\ | | | | | | remove empty unused method
| * add comment to the empty each method for not removing it in futureRajarshi Das2014-07-261-1/+2
|/
* Display diagnostics in text format for xhr requestVlad Bokov2014-04-141-1/+2
|
* Append link to bad code to backtrace when exception is SyntaxErrorBoris Kuznetsov2014-03-271-0/+35
|
* Revert "Merge pull request #9660 from ↵Guillermo Iguaran2013-11-021-6/+0
| | | | | | | | | sebasoga/change_strong_parameters_require_behaviour" This reverts commit c2b5a8e61ba0f35015e6ac949a5c8fce2042a1f2, reversing changes made to 1918b12c0429caec2a6134ac5e5b42ade103fe90. See: https://github.com/rails/rails/pull/9660#issuecomment-27627493
* Merge pull request #9660 from ↵Guillermo Iguaran2013-11-011-0/+6
|\ | | | | | | | | sebasoga/change_strong_parameters_require_behaviour Change ActionController::Parameters#require behavior when value is empty