aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/log_subscriber_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Introduce Template::File as new render file:John Hawthorn2019-03-271-1/+12
| | | | | | | | | | | | | | | | | | | | | | | The previous behaviour of render file: was essentially the same as render template:, except that templates can be specified as an absolute path on the filesystem. This makes sense for historic reasons, but now render file: is almost exclusively used to render raw files (not .erb) like public/404.html. In addition to complicating the code in template/resolver.rb, I think the current behaviour is surprising to developers. This commit deprecates the existing "lookup a template from anywhere" behaviour and replaces it with "render this file exactly as it is on disk". Handlers will no longer be used (it will render the same as if the :raw handler was used), but formats (.html, .xml, etc) will still be detected (and will default to :plain). The existing render file: behaviour was the path through which Rails apps were vulnerable in the recent CVE-2019-5418. Although the vulnerability has been patched in a fully backwards-compatible way, I think it's a strong hint that we should drop the existing previously-vulnerable behaviour if it isn't a benefit to developers.
* Turn lookup context in to a stack, push and pop if formats changeAaron Patterson2019-02-111-2/+1
| | | | | | | | | | | This commit keeps a stack of lookup contexts on the ActionView::Base instance. If a format is passed to render, we instantiate a new lookup context and push it on the stack, that way any child calls to "render" will use the same format information as the parent. This also isolates "sibling" calls to render (multiple calls to render in the same template). Fixes #35222 #34138
* Teach DetailsKey how to clear the template cacheAaron Patterson2019-02-081-2/+2
| | | | | This commit exposes all system wide view paths so that we can clear their caches.
* 🚨 Make the cops happy 🚨Aaron Patterson2019-02-061-1/+1
|
* Move templates to an anonymous subclass of AV::BaseAaron Patterson2019-02-061-1/+4
| | | | | Now we can throw away the subclass and the generated methods will get GC'd too
* Add allocations to template renderer subscriptionEileen Uchitelle2018-10-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | This PR adds the allocations to the instrumentation for template and partial rendering. Before: ``` Rendering posts/new.html.erb within layouts/application Rendered posts/_form.html.erb (9.7ms) Rendered posts/new.html.erb within layouts/application (10.9ms) Completed 200 OK in 902ms (Views: 890.8ms | ActiveRecord: 0.8ms) ``` After: ``` Rendering posts/new.html.erb within layouts/application Rendered posts/_form.html.erb (Duration: 7.1ms | Allocations: 6004) Rendered posts/new.html.erb within layouts/application (Duration: 8.3ms | Allocations: 6654) Completed 200 OK in 858ms (Views: 848.4ms | ActiveRecord: 0.4ms | Allocations: 1539564) ```
* Fix "warning: instance variable @defined_root not initialized"yuuji.yaginuma2017-11-021-1/+1
| | | | | | | | | | | | | | | | | | | | | Currently, the following error is shows only when run the test using `bin/test`. ``` ./bin/test -w test/template/log_subscriber_test.rb Run options: --seed 17167 # Running: /rails/actionview/test/template/log_subscriber_test.rb:34: warning: instance variable @defined_root not initialized ``` In `AVLogSubscriberTest`, if the `Rails.root` is not defined, define the method and undef it in teardown. https://github.com/rails/rails/blob/master/actionview/test/template/log_subscriber_test.rb#L21..L33 However, in `bin/test`, `Rails.root` is defined, which results in referring to uninitialized variables and warnings.
* Use frozen string literal in actionview/Kir Shatrov2017-07-241-0/+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
|
* Merge pull request https://github.com/rails/rails/pull/28637 from ↵Kasper Timm Hansen2017-06-081-21/+26
| | | | st0012/fix-partial-cache-logging
* Use a hash to record every partial's cache hit status instead of sharing a ↵Stan Lo2017-06-081-0/+40
| | | | boolean.
* Use recyclable cache keys (#29092)David Heinemeier Hansson2017-05-181-1/+1
|
* Remove deprecated support to :text in renderRafael Mendonça França2016-10-101-1/+1
|
* Extract common view cache dependency setup.Kasper Timm Hansen2016-08-071-8/+9
|
* Modify LogSubscriber for single partial's cache message.Stan Lo2016-08-081-6/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement naive partial caching mechanism. Add test for LogSubscriber Use ActionView::Base#log_payload to store log_subscriber's payload, so we can pass cache result into it. Fixed tests Remove useless settings Check if #log_payload exists before calling it. Because other classes also includes CacheHelper but don't have is attribute Use @log_payload_for_partial_reder instead of #log_payload to carry ActionView's payload. Update test's hash syntax Add configuration to enable/disable fragment caching logging Remove unless test and add new test to ensure cache info won't effect next rendering's log Move :enable_fragment_cache_logging config from ActionView to ActionPack Apply new config to tests Update actionview's changelog Update configuration guide Improve actionview's changelog Refactor PartialRenderer#render and log tests Mute subscriber's log instead of disabling instrumentation. Fix typo, remove useless comment and use new hash syntax Improve actionpack's log_subscriber test Fix rebase mistake Apply new config to all caching intstrument actions
* modernizes hash syntax in actionviewXavier Noria2016-08-061-8/+8
|
* applies new string literal convention in actionview/testXavier Noria2016-08-061-3/+3
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Added log "Rendering ...", when starting to render a template, to log that ↵Vipul A M2016-02-261-3/+6
| | | | | | | | we have started to render something, at the very beginning. This helps to easily identify queries from controller vs views Fixes #23710
* Instrument cached collection renders.Kasper Timm Hansen2016-02-201-3/+17
| | | | | | | | | | | | | | | | Augments the collection caching with some instrumentation that's logged. For collections that have been cached like: ```ruby <%= render partial: 'notifications/notification', collection: @notifications, cached: true %> ``` We'll output a line showing how many cache hits we had when rendering it: ``` Rendered collection of notifications/_notification.html.erb [0 / 100 cache hits] (3396.5ms) ```
* Removed Mocha from Action ViewRonak Jangir2015-09-231-33/+54
|
* Move template tests from actionpack to actionviewPiotr Sarnacki2013-06-201-0/+91