aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/lookup_context_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Always reject files external to appJohn Hawthorn2019-04-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, when using `render file:`, it was possible to render files not only at an absolute path or relative to the current directory, but relative to ANY view paths. This was probably done for absolutely maximum compatibility when addressing CVE-2016-0752, but I think is unlikely to be used in practice. Tihs commit removes the ability to `render file:` with a path relative to a non-fallback view path. Make FallbackResolver.new private To ensure nobody is making FallbackResolvers other than "/" and "". Make reject_files_external_... no-op for fallbacks Because there are only two values used for path: "" and "/", and File.join("", "") == File.join("/", "") == "/", this method was only testing that the absolute paths started at "/" (which of course all do). This commit doesn't change any behaviour, but it makes it explicit that the FallbackFileSystemResolver works this way. Remove outside_app_allowed argument Deprecate find_all_anywhere This is now equivalent to find_all Remove outside_app argument Deprecate find_file for find Both LookupContext#find_file and PathSet#find_file are now equivalent to their respective #find methods.
* Don't compact formatsJohn Hawthorn2019-03-191-5/+0
|
* Improve "raises on invalid format assignment" testJohn Hawthorn2019-03-181-2/+2
|
* Raise in LookupContext#formats= on invalid formatJohn Hawthorn2019-03-181-0/+8
| | | | | | This is a developer quality of life improvement, to ensure that unknown formats aren't assigned (which it would previously accept, but wouldn't work 100% correctly due to caching).
* Make uniq in LookupContext#formats=John Hawthorn2019-03-181-1/+1
| | | | | Having a format listed twice had no effect. This is mostly helpful to avoid an extra format when assigning [:html, "*/*"]
* Ignore nil in LookupContext#formats=John Hawthorn2019-03-181-0/+5
| | | | | This also removes the mutation we were performing on the values being passed in.
* Make Template::Resolver always cacheJohn Hawthorn2019-03-151-50/+0
| | | | | | | | | | | | All actionview caches are already cleared at the start of each request (when Resolver.caching is false) by PerExecutionDigestCacheExpiry, which calls LookupContext::DetailsKey.clear (which clears all caches). Because caches are always cleared per-request in dev, we shouldn't need this extra logic to compare mtimes and conditionally reload templates. This should make templates slightly faster in development (particularly multiple renders of the same template)
* Create templates with format=nilJohn Hawthorn2019-02-261-2/+2
|
* Templates have one formatAaron Patterson2019-02-251-1/+1
| | | | | | | Templates only have one format. Before this commit, templates would be constructed with a single element array that contained the format. This commit eliminates the single element array and just implements a `format` method. This saves one array allocation per template.
* Deprecate LookupContext#rendered_formatAaron Patterson2019-02-191-0/+10
| | | | | We no longer depend on `rendered_format` side effects, so we can remove this method now. 🎉
* Deprecate `with_fallbacks` using a blockAaron Patterson2019-01-281-6/+19
| | | | | | | This patch changes `with_fallbacks` to be a factory method that returns a new instance of a lookup context which contains the fallback view paths in addition to the controller specific view paths. Since the lookup context is more "read only", we may be able to cache them
* Make `@view_paths` on the lookup context mostly read-onlyAaron Patterson2019-01-281-3/+7
| | | | | | The `with_fallbacks` method will temporarily mutate the lookup context instance, but nobody can call the setter, and we don't have to do a push / pop dance.
* Remove method named "hash"Aaron Patterson2019-01-281-6/+6
| | | | | | We can't use the FixtureResolver as a hash key because it doesn't implement `hash` correctly. This commit renames the method to "data" (which is just as unfortunately named :( )
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-211-7/+5
| | | | | | | | | | 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.
* Replace `assert !` with `assert_not`Daniel Colson2018-04-191-1/+1
| | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-1/+1
|
* 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
|
* improve error message when include assertions failMichael Grosser2016-09-161-2/+2
| | | | | | assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
* Add three new rubocop rulesRafael Mendonça França2016-08-161-1/+1
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+0
|
* modernizes hash syntax in actionviewXavier Noria2016-08-061-1/+1
|
* Use `Mime[:foo]` instead of `Mime::Type[:FOO]` for back compatJeremy Daer2015-10-061-1/+1
| | | | | | | | | | | | | | | | | Rails 4.x and earlier didn't support `Mime::Type[:FOO]`, so libraries that support multiple Rails versions would've had to feature-detect whether to use `Mime::Type[:FOO]` or `Mime::FOO`. `Mime[:foo]` has been around for ages to look up registered MIME types by symbol / extension, though, so libraries and plugins can safely switch to that without breaking backward- or forward-compatibility. Note: `Mime::ALL` isn't a real MIME type and isn't registered for lookup by type or extension, so it's not available as `Mime[:all]`. We use it internally as a wildcard for `respond_to` negotiation. If you use this internal constant, continue to reference it with `Mime::ALL`. Ref. efc6dd550ee49e7e443f9d72785caa0f240def53
* compare arrays not set objects.Aaron Patterson2015-09-211-3/+3
|
* Removed Mocha from ActionView part 1Ronak Jangir2015-08-241-30/+36
|
* Fix the resolver cache and stop mutating the lookup_contextRafael Mendonça França2014-03-141-13/+0
| | | | | Before we had a bug in the resolver cache so the disable_cache were not working when passing options to find
* Introduce #with_formats_and_variants to prevent problems with mutating ↔Ɓukasz StrzaƂkowski2014-03-141-0/+13
| | | | finder object
* Ensure LookupContext in Digestor selects correct variantPiotr Chmolowski2014-03-091-0/+14
| | | | | | | | | | Related to: #14242 #14243 14293 Variants passed to LookupContext#find() seem to be ignored, so I've used the setter instead: `finder.variants = [ variant ]`. I've also added some more test cases for variants. Hopefully this time passing tests will mean it actually works.
* Action Pack VariantsƁukasz StrzaƂkowski2013-12-041-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By default, variants in the templates will be picked up if a variant is set and there's a match. The format will be: app/views/projects/show.html.erb app/views/projects/show.html+tablet.erb app/views/projects/show.html+phone.erb If request.variant = :tablet is set, we'll automatically be rendering the html+tablet template. In the controller, we can also tailer to the variants with this syntax: class ProjectsController < ActionController::Base def show respond_to do |format| format.html do |html| @stars = @project.stars html.tablet { @notifications = @project.notifications } html.phone { @chat_heads = @project.chat_heads } end format.js format.atom end end end The variant itself is nil by default, but can be set in before filters, like so: class ApplicationController < ActionController::Base before_action do if request.user_agent =~ /iPad/ request.variant = :tablet end end end This is modeled loosely on custom mime types, but it's specifically not intended to be used together. If you're going to make a custom mime type, you don't need a variant. Variants are for variations on a single mime types.
* `ActionView::MissingTemplate` for partials includes underscore.Yves Senn2013-12-021-2/+2
| | | | | | Missing partial folder/_partial instead of folder/partial. Closes #13002.
* Fix AV tests, I18nProxy was moved to AVƁukasz StrzaƂkowski2013-08-251-1/+1
|
* Move template tests from actionpack to actionviewPiotr Sarnacki2013-06-201-0/+263