aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/render_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate ActionView::PathSet as argument to ActionView::Base.newCliff Pruitt2019-02-201-0/+4
| | | | Currently, `ActionView::Base.new` will raise a `NotImplementedError` when given an instance of `ActionView::PathSet` on initialization. This commit prevents the raised error in favor of a deprecation warning.
* Move inline rendering content-type test to a controller testAaron Patterson2019-02-191-5/+0
| | | | | | This commit is to remove direct access to the "rendered_format" attribute on the lookup context. "rendered_format" is an implementation detail that we shouldn't test directly.
* Add a test that writes to the collection cacheAaron Patterson2019-02-191-1/+8
|
* Merge pull request #35293 from rails/remove-rendered-format-from-cacheAaron Patterson2019-02-191-1/+1
|\ | | | | Pass the template format to the digestor
| * Pass the template format to the digestorAaron Patterson2019-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit passes the template format to the digestor in order to come up with a key. Before this commit, the digestor would depend on the side effect of the template renderer setting the rendered_format on the lookup context. I would like to remove that mutation, so I've changed this to pass the template format in to the digestor. I've introduced a new instance variable that will be alive during a template render. When the template is being rendered, it pushes the current template on to a stack, setting `@current_template` to the template currently being rendered. When the cache helper asks the digestor for a key, it uses the format of the template currently on the stack.
* | Show deprecated message instead of raise exception in ↵yuuji.yaginuma2019-02-161-0/+7
|/ | | | | | | | | | | | | `compiled_method_container` method Since #35036, the subclasses of `ActionView::Base` requires the `compiled_method_container`. This is incompatible. For example, `web-console` use view class that subclass of `ActionView::Base`, and does not work it now cause of this. Actually, since it seems that it is only `ActionView::Base` that `compiled_method_container` is necessary, modified the condition that emits a warning.
* Merge pull request #35253 from rails/cached-collections-must-have-a-templateAaron Patterson2019-02-131-0/+11
|\ | | | | Cached collections only work if there is one template
| * Cached collections only work if there is one templateAaron Patterson2019-02-131-0/+11
| | | | | | | | | | Cached collections only work if there is one template. If there are more than one templates, the caching mechanism doesn't have a key.
* | Turn lookup context in to a stack, push and pop if formats changeAaron Patterson2019-02-111-2/+5
| | | | | | | | | | | | | | | | | | | | | | 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
* | Adding another failing test caseAaron Patterson2019-02-111-1/+10
| |
* | Add a failing test for #35222Aaron Patterson2019-02-111-0/+6
|/
* Always call superAaron Patterson2019-02-081-2/+0
|
* Teach DetailsKey how to clear the template cacheAaron Patterson2019-02-081-6/+5
| | | | | This commit exposes all system wide view paths so that we can clear their caches.
* Pull generated methods up in to the anonymous subclassAaron Patterson2019-02-061-8/+1
| | | | Then we don't need the extra module.
* Move templates to an anonymous subclass of AV::BaseAaron Patterson2019-02-061-2/+19
| | | | | Now we can throw away the subclass and the generated methods will get GC'd too
* Take in to account optional arguments when deprecatingAaron Patterson2019-02-041-0/+9
| | | | Refs: rails/jbuilder#452
* Pass source to template handler and deprecate old style handlerAaron Patterson2019-02-011-3/+12
| | | | | | | | | This commit passes the mutated source to the template handler as a parameter and deprecates the old handlers. Old handlers required that templates contain a reference to mutated source code, but we would like to make template objects "read only". This change lets the template remain "read only" while still giving template handlers access to the source code after mutations.
* add tests to make sure deprecated API is still supportedAaron Patterson2019-01-311-0/+10
|
* Tighten up the AV::Base constructorAaron Patterson2019-01-291-1/+1
| | | | | | | | | | | | | | | The AV::Base constructor was too complicated, and this commit tightens up the parameters it will take. At runtime, AV::Base is most commonly constructed here: https://github.com/rails/rails/blob/94d54fa4ab641a0ddeb173409cb41cc5becc02a9/actionview/lib/action_view/rendering.rb#L72-L74 This provides an AV::Renderer instance, a hash of assignments, and a controller instance. Since this is the common case for construction, we should remove logic from the constructor that handles other cases. This commit introduces special constructors for those other cases. Interestingly, most code paths that construct AV::Base "strangely" are tests.
* 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 ```
* Don’t allocate array on no argsschneems2018-09-071-1/+1
| | | | | | | | | | When no dependencies are present to be digested there is no reason to build an array just to turn around and turn it back into a string. The dependencies array is not mutated in this method so we can use the same empty array across all invocations. Total allocated: 791402 bytes (7294 objects) Total allocated: 777442 bytes (7132 objects) (791402 - 777442) / 791402.0 # => 1.76 % speed improvement
* 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.
* Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-021-0/+1
|\ | | | | | | Enforce frozen string in Rubocop
| * Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| |
* | Make ActionView frozen string literal friendly.Pat Allan2017-06-201-2/+2
|/ | | | Plus a couple of related ActionPack patches.
* Define path with __dir__bogdanvlviv2017-05-231-2/+2
| | | | | | ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f
* Use recyclable cache keys (#29092)David Heinemeier Hansson2017-05-181-3/+3
|
* Should escape meta characters in regexpRyuta Kamizono2017-05-071-2/+2
|
* Add tests for render template/partial with variants option.Stan Lo2017-04-141-0/+8
|
* Add information on `:formats` option in action_view_overview.mdkenta-s2017-02-061-2/+1
|
* Fix CI failure caused by aa647b46cce55ec12f5895e403c0d1b85502c8e0Ryuta Kamizono2017-02-021-1/+1
|
* Fix test failures only seen when executed via bin/testAkira Matsuda2017-02-021-1/+1
| | | | | sub_template_message distracts Rails.root from its message only when Rails.root is defined, and Rails.root is defined at tools/test.rb
* Merge pull request #27795 from meagar/fix-missing-partial-iterationRafael França2017-01-311-0/+9
|\ | | | | Fix missing partial iteration
| * Add partial iteration variable to template keysMatthew Eagar2017-01-251-0/+9
| | | | | | | | | | | | | | When rendering heterogeneous collection using `render @collection` or `render partial: @collection`, the expected `<partial_name>_iteration` variable is missing due to `find_template` not having the name of the iteration variable included in its cache keys.
* | Get neglected TODO done in render_testkenta-s2017-01-241-2/+1
|/
* Reduce string objects by using \ instead of + or << for concatenating stringsAkira Matsuda2017-01-121-5/+5
| | | | (I personally prefer writing one string in one line no matter how long it is, though)
* Remove unneeded Deprecation silenceRafael Mendonça França2017-01-061-5/+3
|
* improve error message when include assertions failMichael Grosser2016-09-161-1/+1
| | | | | | 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-7/+7
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* modernizes hash syntax in actionviewXavier Noria2016-08-061-99/+99
|
* applies new string literal convention in actionview/testXavier Noria2016-08-061-41/+41
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Use Ruby >= 1.9 hash syntax as is the preferenceSteven Harman2016-07-261-1/+1
|
* Fix collection_from_options to allow EnumeratorsSteven Harman2016-07-261-0/+8
| | | | | | | | | | | | | An optimization was introduced in https://github.com/rails/rails/commit/27f4ffd11a91b534fde9b484cb7c4e515ec0fe77 which tried to `#to_ary` the collection to prevent unnecessary queries for ActiveRecord scopes/relations. If the given collection did not respond to `#to_ary`, and empty collection was returned. That meant you couldn't use collections built from `Enumerator` nor `Enumerable`. With this change, `#collection_from_options` will attempt the optimization, but fall back to passing along the given collection, as-is.
* Change the raw template handler to render html-safe stringseileencodes2016-06-211-0/+7
| | | | | | | | | | | | | | | In PR #24929 the changelog was updated to make note that while the new template handler was changed to raw this changed the behavior when outputting plain html or js files. Previously ERB would output the files unescaped. Changing the default handler to RAW meant that these same files would be rendered as escaped rather than as js or html. Because of this change in behavior and after the discussion #24949 in we decided to change the behavior of the Raw handler to output html_safe strings by default. Now files rendered with the default handler (raw) render the file unescaped.
* Add render allows unicode text name in partials - 🍣Vipul A M2016-04-171-0/+4
|
* Fix partial rendering with dot in filenameBenjamin Quorning2016-03-041-0/+5
| | | | | | | | When rendering a collection with a partial whose filename contains a dot, e.g. "customer.mobile", we would set a `locals[:'customer.mobile']` variable instead of, as in earlier versions of Rails, `locals[:customer]`. This bug was introduced in da9038eaa5d19c77c734a044c6b35d7bfac01104.
* Make collection caching explicit.Kasper Timm Hansen2016-02-201-26/+29
| | | | | | | | | | | | Having collection caching that wraps templates and automatically tries to infer if they are cachable proved to be too much of a hassle. We'd rather have it be something you explicitly turn on. This removes much of the code and docs to explain the previous automatic behavior. This change also removes scoped cache keys and passing cache_options.
* WIP: Errors in logs should show log tags as well.Vipul A M2016-02-121-3/+3
| | | | | | | - Changed formatted_code_for to return array of logs to be tagged for each line - Changed some render tests to match new behaviour of return Fixes #22979
* Merge branch '5-0-beta-sec'Aaron Patterson2016-01-251-0/+7
|\ | | | | | | | | | | | | | | | | | | | | * 5-0-beta-sec: bumping version fix version update task to deal with .beta1.1 Eliminate instance level writers for class accessors allow :file to be outside rails root, but anything else must be inside the rails view directory Don't short-circuit reject_if proc stop caching mime types globally use secure string comparisons for basic auth username / password